oblique sysadmin strategies

Unix Sysadmin Aphorisms

Don’t rewrite cat -n

I had forgotten these aphorisms, until I saw that BBedit ships with some shell scripts, one of which is below:

#!/usr/bin/perl -w
my $i = 0;
while(<>)
{
$i++;
print sprintf("%4d: ",$i), $_;
}

That’s what cat -n does.


[/home/paul]:: perl catdashn < catdashn 1: #!/usr/bin/perl -w 2: my $i = 0; 3: while(<>) 4: { 5: $i++; 6: print sprintf("%4d: ",$i), $_; 7: } (paul@green.paulbeard.org)-(09:44 PM / Thu Jul 24) [/home/paul]:: cat -n catdashn 1 #!/usr/bin/perl -w 2 my $i = 0; 3 while(<>) 4 { 5 $i++; 6 print sprintf("%4d: ",$i), $_; 7 }

Not a big deal, but surely a more meaty example could have been found, and of course, the argument that aphorism is making is not to build something for which a tool already exists.

These aphorisms should be hanging in every IT work area: we used them at my last tech job, especially "what did you do? who did you tell?" In a decentralized work environment, that's essential, and we found that it worked very well.