GNU bug report logs -
#56764
Sed man page omits 'g' flag for substitute command
Previous Next
To reply to this bug, email your comments to 56764 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-sed <at> gnu.org
:
bug#56764
; Package
sed
.
(Mon, 25 Jul 2022 18:09:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Tom Ekberg <tekberg <at> uw.edu>
:
New bug report received and forwarded. Copy sent to
bug-sed <at> gnu.org
.
(Mon, 25 Jul 2022 18:09:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The sed man page has a synopsis for the substitute command (s) which is:
s/regexp/replacement/
I have to go to the sed FAQ (http://sed.sourceforge.net/grabbag/tutorials/sedfaq.txt), section 3.1.3, Substitution switches, to get a list of the possible switches. While there are 8 switches I use 'g' most often to do a global search/replace on the input line. Without this, only the first match is replaced. The FAQ also describes the 'I' switch for doing a case-insensitive search which may be useful in certain cases. The other 6 switches I have never used: N (a number), p, w, M, S, and X.
The version and date on the Ubuntu 20.04 sed man page is sed 4.7, December 2018. The AIX V7.1 man page for sed does contain a description of the 's' switches (flags). Here is what that man page says about the 's' command:
s/pattern/replacement/flags
Substitutes the replacement string for the first occurrence of the
pattern parameter in the pattern space. Any character that is
displayed after the s subcommand can substitute for the / (slash)
separator except for the space or new-line character.
See the Pattern Matching section of the ed command.
The value of the flags variable must be zero or more of:
g
Substitutes all non-overlapping instances of the pattern
parameter rather than just the first one.
n
Substitutes for the n-th occurrence only of the pattern
parameter.
p
Writes the pattern space to standard output if a
replacement was made.
w WFile
Writes the pattern space to the WFile variable if a
replacement was made. Appends the pattern space to the
WFile variable. If the WFile variable was not already
created by a previous write by this sed script, the sed
command creates it.
I was unable to find a version number on the AIX sed man page or the executable (cat /usr/bin/sed |strings -3|sort|uniq|less). That man page doesn't list a -version or -V command line option. They don't work anyway.
The sed man page should, when describing the 's' command, at least describe the 'g' switch, and maybe also describe the 'I' switch.
Tom Ekberg
Senior Computer Specialist
Department of Laboratory Medicine and Pathology
4th Floor, Pat Steel Building, currently WFH
Home: (253) 561-2509
Email: tekberg <at> uw.edu<mailto:tekberg <at> uw.edu>
[Message part 2 (text/html, inline)]
This bug report was last modified 2 years and 104 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.