bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pathname expansion part two


From: Greg Wooledge
Subject: Re: pathname expansion part two
Date: Fri, 15 Oct 2010 15:10:13 -0400
User-agent: Mutt/1.4.2.3i

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

[Prev in Thread] Current Thread [Next in Thread]