[Bro-Dev] #558: /topic/gilbert/ascii-header
Gregor Maier
gregor at icir.org
Thu Aug 18 10:45:09 PDT 2011
> Yes, I think it does what I think it does. :-) THis prints the
> separator as I would expect it to:
>
> echo -e "#separator ;\n1;2;3;4\n" | awk '/#separator/ {FS=$2; print $2}'
>
> But it doesn't apply the new FS, at least on my Mac awk.
I don't know but it works on mine. What's the problem you are facing?
The new FS will only apply to the following lines, not the current one.
(And you'll also need a rule for lines without /#separator/):
$ echo -e "#separator ;\n1;2;3;4\n" |\
awk '/#separator/ {FS=$2; print "sep",$2} !/#separator/ { print
"field3",$3} '
sep ;
field3 3
field3
$ uname -a
Darwin tongariro 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7
16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 i386
$ which awk
/usr/bin/awk
cu
Gregor
--
Gregor Maier
<gregor at icir.org> <gregor at icsi.berkeley.edu>
Int. Computer Science Institute (ICSI)
1947 Center St., Ste. 600
Berkeley, CA 94704, USA
http://www.icir.org/gregor/
More information about the bro-dev
mailing list