From: Torsten Mueller on
J G Miller <miller(a)yoyo.ORG> schrieb:

> > Thanks! (You never end learning sed ...)
>
> What annoys me most though, is people who resort to awk to change
> things on one line. awk is for manipulating columns of data, not
> just changing or selecting a single field or two on one line ;)

Never used awk seriously. But indeed over the years I surprised a lot
of people (especially from the Windows world ...) by demonstrating the
features of sed upon a 1GB logfile. This ends up always in unbelieving
eyes and a mutual whisper of "witchcraft" and so on. I really wonder
that sed is still almost unknown even in the Unix world. Younger
people have usually never heard of this.

T.M.
From: J G Miller on
On Thu, 11 Mar 2010 15:25:33 +0100, Torsten Mueller wrote:

> Never used awk seriously.

Hence the joke,

"Grep, and the whole world greps with you,
awk, and you awk alone."

If you want to use awk "seriously", you should be using PERL ;)

PERL has more or less supplanted awk, but awk is still useful
for small, simple manipulations on columns of data.

From: Chris Davies on
J G Miller <miller(a)yoyo.org> wrote:
> What annoys me most though, is people who resort to awk
> to change things on one line. awk is for manipulating columns
> of data, not just changing or selecting a single field or two on
> one line ;)

IMO awk instructions are often easier to read when processing data
separated by whitespace. For example, I can write this:

virsh list |
awk '$3 == "running" {print $2}

or this:
virsh list |
sed -n "/^[^{tab} ]*[{tab} ]\([^{tab} ]*\)[{tab} ]running.*/\1/p'

or an equivalent in Perl, C, etc.

One is definitely clearer (to me) than the other. On the other hand,
the solution showing how sed can process a line /after/ a pattern match
is definitely clearer than what I'd imagine writing in awk.

Chris
From: J G Miller on
On Thu, 11 Mar 2010 16:21:26 +0000, Chris Davies wrote:
> virsh list |
> awk '$3 == "running" {print $2}

virsh list is generating columns of data? yes?

That is exactly the good use for which awk was designed.

It is using awk on a single line of data that I was complaining about.

> On the other hand, the solution showing how sed can process a line
> after/ a pattern match is definitely clearer than what I'd imagine
> writing in awk.

But in awk, after storing any fields in variables for the current line,
you would just use "next" to move to the next line.

The point is awk is best used for extracting bits of information from
columns of data eg telephone numbers from /etc/passwd, rather than
sed which is best used to edit a field in situ.

As always, it depends on what you are trying to achieve and the
type of data will determine which is the best tool to use, and
the tool will be different for different types of jobs.
From: Art Werschulz on
Hi.

J G Miller <miller(a)yoyo.ORG> writes:

> On Thu, 11 Mar 2010 15:25:33 +0100, Torsten Mueller wrote:
>
>> Never used awk seriously.
>
> Hence the joke,
>
> "Grep, and the whole world greps with you,
> awk, and you awk alone."

Here's my musical contribution (for which I have no further verses):

Stop grepping those files
Let's break out in smiles
We've got that free utility ...
GNU awk, GNU awk

--
Art Werschulz (8-{)} "Metaphors be with you." -- bumper sticker
GCS/M (GAT): d? -p+ c++ l++ u+ P++ e--- m* s n+ h f g+ w+ t+ r-
Net: agw(a)dsm.fordham.edu http://www.dsm.fordham.edu/~agw
Phone: Fordham U. (212) 636-6325, Columbia U. (646) 775-6035
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Passover Seder plates !!!
Next: Firefox P.O.S.