On Fri, Oct 15, 2010 at 12:01:11PM -0700, javajo91 wrote:
> "For example, if you wanted to list all of the files in the directories /usr
> and usr2, you could type ls /usr*.  If you were only interested in the files
> beginning with the letters b and e in these directories, you could type ls
> /usr*/[be]* to list them." 

That assumes there are no subdirectories in /usr, which is a silly thing
to assume.

> When i type /usr*/[be]* i do not get all the files within /usr that begin
> with a b or an e but instead get ALL the files within /usr/bin and /usr/etc.

The glob is expanded according to the shell's normal rules.
/usr*/[be]* matches /usr/bin and /usr/etc which are directories on your
system.  No problem so far.

Then the shell passes those results as arguments to the ls command.  So
you're effective running   ls /usr/bin /usr/etc

ls recurses into each directory that is explicitly given as an argument.
If you want it NOT to do that, use the -d option.

Reply via email to