Results 1 to 2 of 2
I am just getting started with Linux (SUSE) and have what seems like a strange result. When applying a wildcard back in the ancient days when I did some Unix ...
- 10-10-2011 #1Just Joined!
- Join Date
- Oct 2011
- Location
- STL, USA
- Posts
- 8
Unexpected ls wildcard results? Am I crazy?
I am just getting started with Linux (SUSE) and have what seems like a strange result. When applying a wildcard back in the ancient days when I did some Unix (or even DOS) I'm sure that a wildcarded directory request only produced a _subset_ of what was in the specified directory. Right? Am I crazy? Why is it that the results I get for ls a* doesn't list the items in the current directory that begin with 'a' but also lists the CONTENTS of those directories? Is this normal or do I have some goofy recursive user option messing with me? Thanks!
- 10-11-2011 #2
So the way that wildcard expansion works, the shell expands the wildcard, and passes the results to the program. The default behaviour of ls when given a directory on the commandline, is to expand that directory.
This is the "ls" output of my test directory:
And this is the "ls" output with a wildcard:Code:alex@niamh:~/test$ ls bash c c++ java ruby
If I do not want ls to expand directories, I can use the -d option:Code:alex@niamh:~/test$ ls c* c: a.out ckpt_file map_file popen_bash.c read_to_noread_mem.c type_sizes.c bitfields.c file ncurses read_efault.c shmem.c userid.c c++: a.out count.cpp
Code:alex@niamh:~/test$ ls -d c* c c++
DISTRO=Arch
Registered Linux User #388732


Reply With Quote