2 ms·
I find those kind of examples a little unfair as what you're actually doing is comparing the syntax of different shells/languages (the Bourne Shell vs awk). You
by laumars 13y ago
I find those kind of examples a little unfair as what you're actually doing is comparing the syntax of different shells/languages (the Bourne Shell vs awk). You could write examples in Perl or Python as well - to prove how pointless awk and sort is as well if you really wanted. In fact you could even rewrite sort in awk.
While I disagree with most of the comments on here about how:
cat $file | grep "pattern"
is easier to read than
grep "pattern" $file
(in my opinion, if you're a sysadmin then you should know how grep works and thus the optimised solution shouldn't be any harder to read. But at the end of the day, whatever gets the job done).
However I do draw the line at your example because you're now comparing apples to oranges and suggesting that everyone should learn an additional programming language on top of memorising every standard Unix/GNU/BSD command and their flags.
- LukeShu 13y agoWhat about this? <$file grep "patter" It keeps the flow of information left-to-right, but also avoids UUOC.