grep | awk
Thursday, 24 February 2005 09:54Occasionally I see people writing little pipelines using both 'grep' and 'awk'... and it makes me wonder why you start two processes when one will do. (A bit like those who start pipelines with cat file | ... where <file ... will do just as well, and save one process.)
For example, why not replace ... | grep blurfle | awk '{ print $2 }' with ... | awk '/blurfle/ { print $2}'? Or replace ls -l | grep -v '^d' | awk '{total+=$5}END{print total}' with ls -l | awk '$1 !~ /^d/ {total+=$5} END {print total}'?
Especially since most of those recipes use a very simple argument to grep—typically a fixed string, or -v plus a fixed string—which would seem trivially convertible to part of an awk script even without having to learn the full awk language.
Re: defen[cs]e
Date: Thursday, 24 February 2005 15:40 (UTC)Anyway, whatever about the UK (where's that? the Ukraine? :), 'defence' is a perfectly fine Irish spelling. I occasionally use "European English" to include the Irish variety. This has the disadvantage that it sounds absurd, but the usual "British English" sounds absurd anyway, to the millions of English users outside of Britain but within ... these isles.
Re: defen[cs]e
Date: Thursday, 24 February 2005 15:41 (UTC)