DragonFly kernel List (threaded) for 2008-02
DragonFly BSD
DragonFly kernel List (threaded) for 2008-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Globbing


From: Rahul Siddharthan <rsidd120@xxxxxxxxx>
Date: 14 Feb 2008 10:53:48 GMT
Keywords:
Summary:

Bill Hacker wrote:
>That said, I remain surprised that others haven't already said, and
>sooner, rather than later, words to the effect:
>
>'Yes, historical reasons quite aside, these common and frequently needed
>tools can too often be more arcane than they need to be'.

It always surprises me how much of the Unix Hater's Handbook remains
valid.  

For example, how do you use "find" to find all files in a directory
that end in ".el" and don't have a corresponding ".elc" file?  
Answer:
 find . -name '*.el' -print  \
    |sed 's/^/FOO=/' \
    |sed 's/$/; if [ ! -f ${FOO}c ]; then echo $FOO; fi/'  \
    | sh

When I want to do something like that to a large directory, I generate
a full directory listing and then write a python program to parse it.
That seems easier to wrap my mind around.  (The author of the above
find command used emacs-lisp instead, then figured out the correct
find incantation because it bothered him.  "It only took me 12 tries
to get it right.  It only spawns two processes per file in the
directory tree we're iterating over.  It's the Unix Way!")

No doubt Simon or someone will now point out a trivial one-line
invocation of find that will do the job and will be obvious to anyone
who understands the find manpages.

Rahul



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