* [9fans] awk bug or matt bug?
@ 2002-11-18 13:55 matt
2002-11-18 14:22 ` Aharon Robbins
0 siblings, 1 reply; 2+ messages in thread
From: matt @ 2002-11-18 13:55 UTC (permalink / raw)
To: 9fans
I've got some records where I'm trying to extract the b and I ran into this
problem :
9% echo 'a[b]c' | awk ' BEGIN { FS="\[" } { print $2 } '
b]c
9% echo 'a[b]c' | awk ' BEGIN { FS="a\[" } { print $2 } '
awk: malformed '[]'
input record :1
source line 1
I've got a solution but that's not the point
9% echo 'a[b]c' | sed -e 's/\[/!/g' -e 's/]/!/g' | awk ' BEGIN { FS="!" }
{ print $2 } '
b
just thought I'd mention it
m
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [9fans] awk bug or matt bug?
2002-11-18 13:55 [9fans] awk bug or matt bug? matt
@ 2002-11-18 14:22 ` Aharon Robbins
0 siblings, 0 replies; 2+ messages in thread
From: Aharon Robbins @ 2002-11-18 14:22 UTC (permalink / raw)
To: 9fans
It's a matt bug. You need one more \, like so:
$ echo 'a[b]c' | nawk 'BEGIN { FS = "a\\[" } ; { print $2 }'
b]c
The single \ gets eaten during scanning, and awk sees a regex of `a['
which is invalid, thus the second \.
HTH,
Arnold
In article <015401c28f0a$327fdac0$6501a8c0@KIKE> you write:
>I've got some records where I'm trying to extract the b and I ran into this
>problem :
>
>9% echo 'a[b]c' | awk ' BEGIN { FS="\[" } { print $2 } '
>b]c
>
>9% echo 'a[b]c' | awk ' BEGIN { FS="a\[" } { print $2 } '
>awk: malformed '[]'
> input record :1
> source line 1
>
>I've got a solution but that's not the point
>
>9% echo 'a[b]c' | sed -e 's/\[/!/g' -e 's/]/!/g' | awk ' BEGIN { FS="!" }
>{ print $2 } '
>b
>
>just thought I'd mention it
>
>m
>
--
Aharon (Arnold) Robbins --- Pioneer Consulting Ltd. arnold@skeeve.com
P.O. Box 354 Home Phone: +972 8 979-0381 Fax: +1 928 569 9018
Nof Ayalon Cell Phone: +972 51 297-545
D.N. Shimshon 99785 ISRAEL
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-11-18 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-18 13:55 [9fans] awk bug or matt bug? matt
2002-11-18 14:22 ` Aharon Robbins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).