| Date: Tue, 1 May 2007 15:14:37 +0100
| From: "Declan Grady" <declan.grady at nuvotem.com>
|[ ... ]
| for i in `cat $TEMPFILENAME | awk 'BEGIN {FS="_"}{print $1"_"$2}' | sort -u`
| do
| $ADDTIFFFILES `cat $TEMPFILENAME | grep $i\_` $i.tif
| $CONVERTTOPDF $i.tif >$i.pdf
| # do some other stuff
| done
as an aside, this wins a Useless Use of cat Award™.
awk(1) can read files.
so the `cat ... | awk ... | sort -u` backticked(!)
pipe can also be written as:
$( awk -F_ -- '{ print $1 "_" $2 }' "$TEMPFILENAME" | sort -u )
note I've also used the -F option to set FS (rather
then the BEGIN action, just to make the line a bit
more readable (IMHO)), both the -- end-of-options
maker and a "quoted" filename as safety precautions,
and the much-more-readable $( ... ) notation rather
than the obsolete `back ticks`.
( I've also inserted a few (spurious) spaces for
readability, albeit the original is Ok (IMHO). )
as an exercise to the reader, the grep can also be
improved somewhat. however, since there are some
strong assumptions being made about the contents
of $TEMPFILENAME, it is, to some extent, pointless.
apologies, this question just caught me in a very-
annoyed-at-some-scripts mood ..... ;-\
cheers!
-blf-
--
▶ ▶ I AM CURRENTLY LOOKING FOR A JOB! ◀ ◀ | Brian Foster
Experienced (>25 yrs) software engineer: | Montpellier, FRANCE
• Unix, Linux, embedded, design-for-test; | Stop E$$o (ExxonMobile)!
• Software/hardware co-design, debugging; | http:/www.stopesso.com
• Kernels, drivers, filesystems, &tc; Résumé (CV) & contact details:
• IDL, automated testing, process, &tc. http://www.blf.utvinternet.ie
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!