On Fri, Oct 15, 2010 at 01:13:33PM -0600, Bob Proulx wrote: > javajo91 wrote: > > "For example, if you wanted to list all of the files in the directories /usr > > and usr2, you could type ls /usr*. > > Because the '*' is a file glob. It is called a glob because it > matches a glob of characters. The process of the expansion is called > globbing. "/usr*" matches "/usr" and "/usr2" both. That is expanded > on the command line. > > $ ls /usr* > > is the same as > > $ ls /usr /usr2 > > The ls command never sees a '*' because the shell expands it first. > You can use echo to see what the shell has expanded. > > $ echo foo /usr* > foo /usr /usr2
Note, though, that the '*' will still be there if the glob operation fails to expand to anything. $ echo foo /usrz* foo /usrz* I guess this makes sense, since just about all characters can be used in filenames, but I always need to check for this case, e.g., in for loops. Ken