[Techtalk] command line
dominik.schramm at gmxpro.net
dominik.schramm at gmxpro.net
Sat Mar 20 16:09:16 EST 2004
Hi,
"R. Daneel Olivaw" <linuxchix at r-daneel.com> writes:
> #!/bin/sh
> FileList=`find . -name "*.php" -type f -print`
> for phpFile in "`cat ${FileList}`"
This looks unnecessarily complicated, and I don't see -- not at first
glance, at least -- why this would work. Please correct me if I'm
wrong.
find returns a list of files, which are here put into the variable
FileList; then the file (!) with the name $FileList is output,
the output is split into whitespace-separated fields, which get
assigned to phpFile one after the other??
Why not simply do it like this:
find . -name "*.php" -type f -print0 | while read file
do
...
done
Some time ago someone posted the link to the "Useless Use of Cat
Award": http://rhols66.adsl.netsonic.fi/era/unix/award.html
I personally learnt a lot from this page and can recommend it to
anyone wishing to brush up their shell scripting abilities.
It challenged almost every script I've ever written, but still (or
because of this?) it was very worthwile reading.
regards,
dominik
--
Dominik Schramm <dominik.schramm at gmxpro.net>
pgp key via http://www.cam.ac.uk.pgp.net/pgpnet/wwwkeys.html
More information about the Techtalk
mailing list