NetBSD-Bugs archive

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

Aw: Re: bin/48667 (awk: man page for gsub shows wrong order of arguments)



The following reply was made to PR bin/48667; it has been noted by GNATS.

From: "Kai-Uwe Eckhardt" <kuehro%gmx.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Aw: Re: bin/48667 (awk: man page for gsub shows wrong order of
 arguments)
Date: Fri, 21 Mar 2014 19:25:52 +0100

 > 
 > % echo hi | awk '{ sub(".", "x", $0); print $0; }'
 > xi
 > 
 > Seems to me like it's doing what the man page says. Can you clarify?
 
 In the man page s means substition string and t the target string, in which
 teh substitution should take place. So it would be sub(".", $0, "x") 
 according to the man page:
 
 gensub(r, s, h, [t])
              Search the target string t for matches of the regular expression
              r.  If h is a string beginning with g or G, then replace all
              matches of r with s.  Otherwise, h is a number indicating which
              match of r to replace.  If no t is supplied, $0 is used instead.
              Unlike sub() and gsub(), the modified string is returned as the
              result of the function, and the original target is not changed.
              Note that the \n sequences within replacement string s supported
              by GNU awk are not supported at this moment.
 
 gsub(r, t, [s])
              same as sub() except that all occurrences of the regular expres-
              sion are replaced; sub() and gsub() return the number of replace-
              ments.
 
 Kai-Uwe
 


Home | Main Index | Thread Index | Old Index