awk gsub problem

Lee ler762@gmail.com
Wed Sep 15 23:43:00 GMT 2010


I don't know if this is just a problem with the cygwin version of awk,
me misunderstanding something or what, but it looks like gsub isn't
working correctly in awk:
$ sh /tmp/test.awk
s= ::0::  should = ::S0::

$ cat /tmp/test.awk
awk '
BEGIN {
  s="Serial0"
  gsub("[a-z]","",s)
  printf("s= ::%s::  should = ::S0::\n", s)
  exit
} '


I also tried it with IGNORECASE=0 and with "awk --traditional" - same results.

$ which awk
/usr/bin/awk

$ awk --version
GNU Awk 3.1.8
Copyright (C) 1989, 1991-2010 Free Software Foundation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.

$

--- on a Linux box & it works the way I expected:

% sh /tmp/test.awk
s= ::S0::  should = ::S0::

% awk --version
GNU Awk 3.1.5
Copyright (C) 1989, 1991-2005 Free Software Foundation.
  ... snip ...


Regards,
Lee

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list