[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ^ in FS

From: Dave B
Subject: Re: ^ in FS
Date: Wed, 26 Nov 2008 15:09:49 +0100
User-agent: Thunderbird (X11/20081124)

Stepan Kasal wrote:

> I'm afraid I have not selected the best examples; thank you for
> sending your ones.  Asking the right question is bigger part of the
> explanation.  ;-)
> I hope this explains _what_ gawk does.

Definitely! And also why we see the output we see.
With that knowledge, it's easy to purposely build test cases that exhibit
the problem, even if no empty string matching is involved:

$ echo 'XaXbXc' | gawk -F '^X|b' '{for(i=1;i<=NF;i++)print"-->"$i"<--"}'


$ echo 'XaXbXc' | bell_awk -F '^X|b' '{for(i=1;i<=NF;i++)print"-->"$i"<--"}'


$ echo 'XXX' | gawk -F '^X' '{for(i=1;i<=NF;i++)print"-->"$i"<--"}'

$ echo 'XXX' | bell_awk -F '^X' '{for(i=1;i<=NF;i++)print"-->"$i"<--"}'

(this last one is probably the most straightforward way to demonstrate the

In essence, all it takes is finding a string where, after removing some
field, what's left matches the ^ part in the FS regex, even it it's not at
the beginning of the string.

On a side note, I did some tests and saw that mawk and busybox awk also
behave like gawk.

Thank you very much, it's clear now!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]