[wplug] [wplug-announce] UPDATE: WPLUG General User Meeting, Sat. June 12, 10:30a, WSCC

Vance Kochenderfer vkochend at nyx.net
Sat Jun 12 00:47:36 EDT 2010


Hi everyone-

Since we had a recent question about this on the list, and don't
have our original topic for Saturday's meeting, I'm going to talk
a bit about the UNIX text processing utilities such as grep, sed,
awk, cat, wc, and the like.

However, you don't get to just sit on your butt and listen; this
is an audience-participation event.  What we're going to do is
take a couple simple tasks, and then explore how you could
accomplish them using various UNIX utilities.

The goal is not solely to find the standard, quickest, or simplest
solution, but to try out as many different whacked-out options as
we can.  So don't stop thinking once you've got an answer, even if
it's a good one - see what else you can come up with!

We'll talk over all the suggestions and how they work (or don't
work), so hopefully we'll all learn something new.

Start thinking about these, and bring your ideas to the meeting:

EXERCISE ONE

You have a large text file.  Some lines contain text; others are
blank.  Your goal is to figure out how many non-blank lines are in
the file.

I can think of at least six ways of doing this, how about you?

EXERCISE TWO

Determine whether a given value is numeric (decimal).

Example numeric values:
  123       45.6789   -3.4567   -0        000123    .01234
  54321.    00000.    -0.987    -.987     -0123.    012
  0.0       .0        -.000

Example non-numeric values:
  hello     3f        3F        AB        0xAB      0.0.
  -0-       3.0E8     3.0e-08   .-0123    1.23.4    5.678-
  --98      a space   a tab

As a bonus, make your command also consider a value numeric if it
starts with a + instead of a -.

I haven't thought about this one as much, and only have one
solution so far.  Maybe you can come up with something using bc or
some other non-obvious method?

Vance Kochenderfer        |  "Get me out of these ropes and into a
vkochend at nyx.net          |   good belt of Scotch"    -Nick Danger


More information about the wplug mailing list