bug-gnu-utils
[Top][All Lists]
Advanced

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

bug: @^ pattern substitution


From: Wittstruck, Clinton
Subject: bug: @^ pattern substitution
Date: Mon, 11 Jun 2001 15:08:31 -0700

I have encounter a bug (or at least inconsistencies) with pattern
substitution in awk,
on different platforms. While some function as desired, others either crash
or do not
function as desired. The following script demonstrates the problem:

if [ "`uname`" = "SunOS" ] ; then
awk=nawk
else
awk=awk
fi

# in awk, substitute the first occurrence in $0 of @^ with just ^

$awk '{print $0; sub("@\^","^",$0); print $0}' <<END
remove the first "@" sign when followed by ^ address@hidden
END
exit


Trying the above on various platforms...

HP-UX 10.20 and NutCRACKER 4.2a on Windows NT,
function as desired. The output is:

remove the first "@" sign when followed by ^ address@hidden
remove the first "@" sign when followed by ^ ##^##

Solaris 2.7 gets a syntax error:

nawk: syntax error in regular expression @^ at 
 source line number 1
 context is
        {print $0; >>>  sub("@\^","^",$0) <<< 


Linux 7.0 and Cygwin 5.0 on Windows NT, do not function as expected.
The output is:

remove the first "@" sign when followed by ^ address@hidden
remove the first "@" sign when followed by ^ address@hidden




reply via email to

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