Globbing
Adrian Chadd
adrian at FreeBSD.org
Thu Feb 14 04:33:57 PST 2008
find . -type f -name <whatever> | grep *.el$
As long as you're not doing two context switches per line, it should
perform well, and without forking off copies of [ in the old POSIX
case, etc.
I don't get why people keep dissing UNIX shells. Haven't you had to
write a script which ran portably on every real UNIX platform? :)
Adrian
On 14 Feb 2008 11:36:16 GMT, Rahul Siddharthan <rsidd120 at gmail.com> wrote:
> "Simon 'corecode' Schubert" wrote:
> >likewise, with find for subdirs (not POSIX):
> >
> >find . -name '*.el" -exec sh -c 'for f; do [ -f "${f}c" ] || echo "$f"; done' dummy {} +
>
>
> which gives me
> bash: syntax error near unexpected token `do'
>
> The reason is a mismatched quote pair around *.el, which I only
> realised when cut-and-pasting your command into emacs with syntax
> highlighting enabled. I'm impressed that you sent it without trying
> it first, and got it right except for a trivial typo. But for the
> rest of us, doing non-trivial things with the shell is often not worth
> the effort.
>
> For me already python is faster, and not just in terms of thinking
> things through. For example, I tried creating 100,000 files and
> removing them with the "rm" function that you suggested a few emails
> ago. It did the job but took a good long time, and this is a fairly
> fast opteron workstation. In that time, I could have written a python
> program to parse a list of files and remove each one....
>
> A more powerful shell is badly needed. (I believe zsh and others are
> vast improvements on bash, I should check them out.) Of course, not a
> topic for kernel at ...
>
>
> Rahul
>
--
Adrian Chadd - adrian at freebsd.org
More information about the Kernel
mailing list