Bash expanding wildcards?
Somewhere on this site I read a posting that basically explained why I was having newbie trouble with wildcards. It explained that the Bash shell would expand wildcards and then hand them to the command being called. So if I type the command ls a* the ls command would actually receive a line with all the filenames expanded -- and this was giving me the unexpected results, since I then saw the contents of those directories.
ANYWAY -- my question now is: Why does Bash do that? Why would I want that? Do all Linux shells do that? Can I turn that 'feature' off? Thanks!!! |
I'm not sure I understand what your question is, for the example command,
Code:
ls Directory/ Code:
ls a* if you want to list all the directories and files meeting criteria a*, but not the contents of the directories use Code:
ls -d a* |
Quote:
Quote:
|
1. because not all progs/utils etc are have built-in wildcard expansion code
2. saves you writing your own wildcard expansion code (see 1.). Its harder than you think, it's effectively a regex engine... 3. yes 4. google shellopt and bash globbing http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ HTH Welcome to LQ :) |
The solution I like best for listing directories only is;
ls -l | grep '^d' |
All times are GMT -5. The time now is 08:30 AM. |