OT: Need some shell scripting hints
Atro Tossavainen
yellowdog-general@lists.terrasoftsolutions.com
Fri Oct 3 00:47:01 2003
Guy,
> There is always perl, e.g.:
>
> find . -name '*.txt' -exec cat {} \; | perl -ne 'qx(something $_);'
This calls for another Useless Use of Cat award, and you get extra
points for not just spawning a single useless process, but one for
every file found by "find".
You better hope you don't have a directory ending with ".txt" :)
Since Perl can take the list of file names as parameters and they will
appear in the magic <>, why not just
find . -type f -name '*.txt' | xargs perl -ne 'qx(something $_);'
Or why not just avoid the unnecessary piping and xargs and use backticks:
perl -ne 'qx(something $_);' `find . -type f -name '*.txt'`
--
Atro Tossavainen (Mr.) / The Institute of Biotechnology at
Systems Analyst, Techno-Amish & / the University of Helsinki, Finland,
+358-9-19158939 UNIX Dinosaur / employs me, but my opinions are my own.
< URL : http : / / www . helsinki . fi / %7E atossava / >
File attachments NOT welcome unless agreed to beforehand.