Re: pulling out blocks of data from file





On 11/22/2007 4:59 PM, Steffen Schuler wrote:
Hi Ed, hello netlanders,

On Wed, 21 Nov 2007 10:34:09 -0600, Ed Morton wrote:

<snip>

If you aren't using gawk, you might need:

awk -F '\.' -v RS="SERVER" 'prev && ($2 != "prev"){close(prev)} {print >
$2; prev=$2}' file

Regards,

Ed.


you used awk as the name of the awk utility. Normally that means POSIX
awk.

I've never heard that assumption before. I'd certainly never assume that since
most awks I come across are not POSIX compliant.

But then RS should contain at most one character. If you use more
characters, the results are unspecified. But if you use gawk as your awk,
your record separator would work correctly.

That's true. I've no idea what other awks allow multi-character field
separators. I should probably have said something like "If you're using an awk
that supports multi-character RSs other than gawk" rather than just "If you
aren't using gawk".


Ed, please note that also in your definition of the field separator,
newline is always an additional field separator for multiline records,
regardless of the value of FS. (See "The AWK Programming Language" p. 84)

That may be true for old, broken awk (which, I think, was the only one around
when that book was written) but it's not true for modern awks like gawk:

$ cat file
a.b.c
d.e.f

g.h.i
k.l.m

$ awk -F'.' -v RS= '{print $2}' file
b
h


Ed you helped me so much in the last years, I hope I could help you too a
bit.

Yes, thank you.

Ed.

.



Relevant Pages

  • Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)
    ... You attempted to hijack my simple observation ("awk is the standard name, gawk ... I could also teach busybox awk to be called as "gawk", ...
    (Linux-Kernel)
  • Re: sed _s_gnu_alternatives_ (Re: [rft] (g)awk substitution)
    ... You attempted to hijack my simple observation ("awk is the standard name, gawk ... I could also teach busybox awk to be called as "gawk", ...
    (Linux-Kernel)
  • Re: Automatisierte TextVerarbeitung
    ... AWK - oder bessergesagt "awk" kam mir doch gleich irgendwie bekannt vor ... Einige kann man auch als exe fuer Windows beziehen ... Ich habe soeben ein altes mawk herausgekramt und ein mini-awk script, ... Betreff: Re: where are the binaries for GAWK? ...
    (microsoft.public.de.german.windowsxp.sonstiges)
  • Re: pulling out blocks of data from file
    ... That may be true for old, broken awk (which, I think, was the only one ... I found in the gawk manual for gawk 3.1.6 in the section 3.7 ... the newline character always acts as a field separator. ...
    (comp.lang.awk)
  • Re: sometimes awk works and sometimes /usr/xpg4/bin/awk works ..
    ... gawk, I knew it would be hopeless to simply increment, so I went to doubling. ... So if you want a version of awk that for most practical purposes doesn't have ... again install patches without that particular problem. ... the patching scripts in perl, ...
    (comp.unix.solaris)