As @Sparhawk explained, what is happening is that you are listing the content of the directories. This will not depend on the *nix you are using, as far as I know, this is the default behavior of GNU ls
. Non-GNU implementations may be different but I doubt it.
When you run this command:
ls /usr/include/*6*
The glob (*6*
) is expanded by your shell (bash for example) before calling ls
. So, given the following directory structure:
.
├── dir1
│ ├── file1
│ └── file2
└── dir2
├── file1
└── file2
ls d*
will be expanded to ls dir1 dir2
, and give the results you expect:
dir1:
file1 file2
dir2:
file1 file2
This is how ls
deals with multiple target directories by default, it lists each directory found and then the contents of that directory. However, if you run it on a single directory, the name is not printed:
$ ls d*1
file1 file2
So, since there is only one match for the glob *6*
in /usr/include
and that match is a directory, you are running ls
with a single directory as input and, therefore, it is listing the contents of the directory without including the directory name.
-d
:ls -d /usr/include/*6*
. – Eric Carvalho Mar 24 '14 at 01:32ls
used to show a directory before list of files from this directory. Including the Mac OS X, where I can see a bunch of directories, containing the digit6
, followed by files from these directories. – HEKTO Mar 24 '14 at 02:06