the joy and non-joy of globbing

John Summerfied debian at
Wed Dec 21 12:18:37 UTC 2005

Robert P. J. Day wrote:
>   as a quick demonstration on how globbing might run into the shell
> limits, try the following few commands.  first, just try:
>   $ ls /*
> the output of this command is not important, all that's important is
> that the shell had to expand the wildcarding to generate the command
> to run.
>   if that worked, push it a bit harder:
>   $ ls /*/*
>   if that worked, a bit harder still:
>   $ ls /*/*/*
> sooner or later, you'll hit the shell's limit as to just how large a
> command it can construct.

which is why I'm for ever telling people, "Don't do that." Especially in 

This is far more robust:
find <paths> <selection criteria>  <printing instructions> \
| while read name
   do something with ${name}

find <paths> <selection criteria> <printing instructions>\
	| xargs --no-run-if-empty <more args> something with

Sometimes this is appropriate:
find <paths> <selection criteria> -exec prog {} \;

Note: watch out for spaces in names. They're legal, but cause havoc for 
the unwary.

Read the man pages for
bash <:-)>



-- spambait
1aaaaaaa at  Z1aaaaaaa at
Tourist pics

do not reply off-list

More information about the fedora-list mailing list