Re: pulling out blocks of data from file
- From: Ed Morton <morton@xxxxxxxxxxxxxx>
- Date: Thu, 22 Nov 2007 17:25:40 -0600
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.
.
- Follow-Ups:
- Re: pulling out blocks of data from file
- From: Steffen Schuler
- Re: pulling out blocks of data from file
- References:
- pulling out blocks of data from file
- From: dwcasey
- Re: pulling out blocks of data from file
- From: Ed Morton
- Re: pulling out blocks of data from file
- From: dwcasey
- Re: pulling out blocks of data from file
- From: Janis Papanagnou
- Re: pulling out blocks of data from file
- From: Steffen Schuler
- Re: pulling out blocks of data from file
- From: Janis Papanagnou
- Re: pulling out blocks of data from file
- From: dwcasey
- Re: pulling out blocks of data from file
- From: Janis
- Re: pulling out blocks of data from file
- From: dwcasey
- Re: pulling out blocks of data from file
- From: Ed Morton
- Re: pulling out blocks of data from file
- From: Steffen Schuler
- pulling out blocks of data from file
- Prev by Date: Re: pulling out blocks of data from file
- Next by Date: Re: *really* shortest match in awk - possible?
- Previous by thread: Re: pulling out blocks of data from file
- Next by thread: Re: pulling out blocks of data from file
- Index(es):
Relevant Pages
|