[PLUG] Re: Okay after awk I need....

Aaron Burt aaron at bavariati.org
Sat May 7 20:35:06 UTC 2005


On Sat, May 07, 2005 at 12:23:52PM -0700, AthlonRob wrote:
> Aaron Burt wrote:
> > On Sat, May 07, 2005 at 06:03:06AM -0700, Randal L. Schwartz wrote:
> >>If this had been comp.unix.questions, you would have been the
> >>winner of this week's "Useless Use Of Cat" award.
> >><http://laku19.adsl.netsonic.fi/era/unix/award.html>
> > 
> > Wow.  ~100 characters to criticize the use of 3.  And at least the 3
> > characters improve readability IMHO.
> 
> And how many characters to criticize the use of those ~100 characters?  ;-)

Fewer.

> By *teaching* people when to use cat and when not to use cat, you may
> save characters for lifetimes to come.

I understand that The One True Correct Way To Use Cat [sic] is to
concatenate multiple files and pipe them to stdout, and anything else
is a horrible, shameful UUOC, so do it in private and wash your hands
afterwards.  

Luckily for us, this is *nix, and there many ways to do things, nearly
all of them hackishly built up with little utilities being used in
ways their authors never bothered to think of.  That's the Unix Way.

> I disagree about the readability thing - I dislike UUOC and think it
> confuses readability.

For me it's simple:  If you're reading a pipeline, it should go
left-to-right, with minimal ambiguity about where the data's coming
from and what's being done to it.  Using cat removes any question
about where the data's coming from, and you don't have to remember if
the first filter in the pipeline takes its input file as a plain
parameter, a -f <filename>, a -i <filename> or something else, or only
as a redirect.  You don't have to figure out which bit is filename and
which is parameter.  And if you want to use some other data source,
it's perfectly obvious that you need only remove the "cat <filename>"
from the beginning.

One-thing-at-a-time readability is especially important when you're
presenting a functional example to a mailing-list with lots of
beginning Linux folks.

But I'd love to know why I'm wrong,
  Aaron



More information about the PLUG mailing list