HP3000-L Archives

May 1997, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Gavin Scott <[log in to unmask]>
Reply To:
Gavin Scott <[log in to unmask]>
Date:
Mon, 12 May 1997 11:53:57 -0700
Content-Type:
text/plain
Parts/Attachments:
Re: (27 lines)
Mark writes:
> Programmers that don't utilize the full power of Unix suck.  ;-)
>
> find /DEV/SOURCE | \
> xargs wc -l | \
> awk ' \
>   $2 == "total" { total = total + $1} \
>   END { print total}'

This works fine unless the user has a file named "total" on the system,
in which case you get the *wrong* answer, and no indication that it is
the wrong answer.  Typical UNIX application :-)

Also you don't know how xargs is going to "batch up" the filenames. If
it ends up only passing one filename to wc at some point then you
don't get a 'total' line, and the result is *wrong* again.

> I like to describe Unix as a collection of tiny building blocks from
> which it is possible to build elegant skyscrapers (or disorganized
> shantytowns that defy building codes).  You are only limited by your
> imagination, or your lack of knowledge of available Unix tools.

Where Microsoft operating systems are so complex that they are almost
impossible to use, UNIX is so simple that it's almost impossible to use.

G.

ATOM RSS1 RSS2