One regularly sees here situations where some poor punter is flamed fro what
the flamer calls useless use of cat e.g. where someone might have said
some_program < file
However, today I came across a necessary, but apparently useless use of cat.
I had a file with a list of images and some characteristics of those images,
including their format. I wanted to extract all JPEGs and TIFFs so I
niall at bagend:/mnt/images :1>egrep "JPEG|TIFF" imagelist.txt
Binary file imagelist.txt matches
niall at bagend:/mnt/images :2>egrep "JPEG|TIFF" < imagelist.txt
Binary file (standard input) matches
niall at bagend:/mnt/images :3>cat imagelist.txt | egrep "JPEG|TIFF"
lots of output
Now a quick perusal of the grep (egrep being of course just grep wearing
fancy clothes) manual taught me that -a was my friend, but I'm still very
puzzled by the difference between 2 and 3, when in each case egrep surely
sees only that it has a non-TTY as its stdin.
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!