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:
Mark Bixby <[log in to unmask]>
Reply To:
Date:
Mon, 12 May 1997 11:23:00 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (49 lines)
Bruce Toback writes:
>
> Gavin writes:
>
> >Jeff writes:
> >> shell/iX> wc -l /DEV/SOURCE/* | tail -1
> >> wc: cannot execute: Arg list too long
> >
> >Unix sucks.
>
> No, Unix is fine. Programmers who don't check boundary conditions suck.

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}'

The above is just one solution.  There is more than one approach you could
take.

The find command lists every file name below /DEV/SOURCE.  The xargs command
iteratively calls wc passing a large number of file names that won't overflow
the argument buffer.  Awk looks for the wc "total" lines to keep a running
total, which is printed when there is no more input to awk.

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.

> This is one instance where MPE, more or less by accident, comes out way
> ahead of Unix.

For me, MPE's great strength is ease of use.  Lots of great macro-scale tools,
reliability, etc.  But if your task falls outside of the available MPE toolset,
you might have to do a lot of coding from scratch.

With Unix, the tools are all micro-scale, and often a new task can be derived
from an existing solution with only minor tweaks.
--
Mark Bixby                      E-mail: [log in to unmask]
Coast Community College Dist.   Web: http://www.cccd.edu/~markb/
District Information Services   1370 Adams Ave, Costa Mesa, CA, USA 92626-5429
Technical Support               +1 714 438-4647
"You can tune a file system, but you can't tune a fish." - tunefs(1M)

ATOM RSS1 RSS2