sed - substitute either of two characters with one command
I would like one sed
command to accomplish the following:
$ sed s'/:/ /g' <and> sed s'/=/ /g'
That is, I would like to write
sed s'/<something>/ /g'
and have both =
and :
replaced by spac开发者_开发百科e.
sed s'/[:=]/ /g'
Brackets mean "any one of".
One option is also to use sed -e
, like this. Although you don't need it in this case, it's however a good option to know about.
sed -e 's/:/ /' -e 's/..../ /' file
Sanjay's answer solves it. Another option that works with only one sed command is to separate each s
substitution with a semicolon
sed 's/:/ /g ; s/=/ /g' file
or in separate lines in a script
sed 's/:/ /g
s/=/ /g' file
Those may be handy in other situations.
精彩评论