User error or awk bug?

Garrett Cooper yanefbsd at gmail.com
Fri Jan 15 22:02:21 UTC 2010


On Fri, Jan 15, 2010 at 1:57 PM, David Wolfskill <david at catwhisker.org> wrote:
> On Fri, Jan 15, 2010 at 01:51:34PM -0800, Garrett Cooper wrote:
>> ...
>> >
>> > d254(6.4-S)[7] echo //////// | awk '{ gsub (/\/{2,}/, ""); print }'
>> > ////////
>> > d254(6.4-S)[8] echo //////// | awk '{ gsub (/\/+/, "/"); print }'
>> > /
>> > d254(6.4-S)[9]
>>
>>     I'm avoiding this because it would create an infinite loop in my
>> awk script (I want to squish slashes, not eliminate them completely
>> :)...).
>
> Errr...  I thought "/\/{2,}/" was a regex referring to "2 or more
> consecutive /", and the replacement was "", which sounds about as close
> to eliminating them completely as I can imagine.  :-}
>
> How about:
>
> d254(6.4-S)[10] echo //////// | awk '{ gsub (/\/\/+/, "/"); print }'
> /
> d254(6.4-S)[11]
>
> then?

    This works very well. Is the expression quantifier operator [ `{'
] not supported in awk like perl, python, tcl, etc?
Thanks,
-Garrett


More information about the freebsd-hackers mailing list