bash - Confusion Regarding ! Character in Sed -
these 2 sed commands appear behave identically:
$ sed "s/^replace=*/replace=mytest/g" test.txt $ sed " s!^replace=*!replace=mytest!g " test.txt
why this? can !
character used instead of /
? not see explanation of !
character in sed documentation.
you should read man-pages more closely :)
3.5 s command
the syntax of s (as in substitute) command ‘s/regexp/replacement/flags’. / characters may uniformly replaced other single character within given s command. / character (or whatever other character used in stead) can appear in regexp or replacement if preceded \ character.
tl;dr
as mentioned in these man-pages, can use single character separator sed regexp
, replacement
.
edit: evil otto crystal clearing :)
Comments
Post a Comment