Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How much of it is zsh?

2010-03-24 14:03:59 +0200, Nadav Har'El:
> You're right that the two commands
> 	egrep -R something dir
> 	egrep something dir/**/*
> basically end up doing the same thing, but I don't see why you should
> consider this a problem. By the way, if you're curious, there's actually
> a subtle difference between the way these two work. Like I said, the shell's
> globbing is always done in advance. So if dir has a million files under it,
> this will expand into a command with a million arguments - which on some
> system can be a problem (too much memory used, or command too long).
> On the other hand, egrep -R finds the files recursively one by one, and
> never needs to hold the whole list of files in memory.

There are a few other differences:
 - grep -R (at least the GNU variant as probably found on
 cygwin) will follow symbolic links when descending directories
 (use dir/***/* to achieve the same with zsh).
 - **/* will ommit dot files and do dirs, use **/*(D) to avoid
 - **/* also sorts the list of files which adds some more overhead but
 produces a more reproducible outcome. Use **/*(oN) to prevent


egrep -R something dir
would be more like:
egrep something dir/***/*(DoN)

grep -E something dir/**/*(.DoN)

would probably be more what you'd want though.


Messages sorted by: Reverse Date, Date, Thread, Author