[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ProgSoc] cat file | prog [was Re: Asking for help from the sed heads]
(I don't know who wrote this, as it's a quote of a quote...)
| >
| > Just copy the lines u want into a text file called tmp.1 then run
| >
| > cat tmp.1 |awk '{print "#include ", $*}' > tmp.2
| >
Let's ignore the syntax error in the script for a moment.
Does anyone know if we have anything in TFM which berates people who use
"cat file" at the head of a shell pipeline? Because we should.
For those not in the know, the above one-liner is more cluefully written
as:
awk '{print "#include ", $*}' < tmp.1 > tmp.2
or even better:
awk '{print "#include ", $*}' tmp.1 > tmp.2
Some of you may think that complaining about this is being particularly
anal, but it's these avoidable inefficiencies that give Unix a bad name
("To get this to work in Unix, I need to launch 50,000 processes!").
Another example: on one host I found a set of shell scripts which had
many lines like this in them:
var2=`echo $var1`
No prizes for those who can figure out the clueful way of doing this.
Cheers,
--
Dennis Clark dbugger@nospam.debian.org PGP/MIME spoken here
-------------------------------------------------------------------------------
A complex system that works is invariably found to have evolved from a
simple system that works.
PGP signature