Comments on: Using different delimiters in sed https://backreference.org/2010/02/20/using-different-delimiters-in-sed/ Proudly uncool and out of fashion Wed, 26 Dec 2018 22:09:44 +0000 hourly 1 https://wordpress.org/?v=5.8.2 By: Me https://backreference.org/2010/02/20/using-different-delimiters-in-sed/#comment-25415 Wed, 26 Dec 2018 22:09:44 +0000 http://backreference.org/?p=8#comment-25415 I’ve often used this feature of sed for search/replace lists with my colleagues... I just tell them to create me a spreadsheet with “find” string in first cell and replace in second... then export to text... a little recursive sed script using either spaces or commas as delimiter/separator is magic to them.....

]]>
By: waldner https://backreference.org/2010/02/20/using-different-delimiters-in-sed/#comment-25216 Wed, 26 Aug 2015 10:28:59 +0000 http://backreference.org/?p=8#comment-25216 In reply to John.

It just has to be escaped, as explained in the article and in the sed docs.

sed '\_this_d' test
etc.
]]>
By: John https://backreference.org/2010/02/20/using-different-delimiters-in-sed/#comment-25209 Thu, 30 Jul 2015 12:50:24 +0000 http://backreference.org/?p=8#comment-25209 Note that this does not work when the sed expression begins with the delimiter, such as the 'delete' case or 'change only lines that have this text' case:

$ cat test
this
that
this
orthat
orthis
$
$ sed '/this/d' test
that
orthat
$
$ sed '_this_d' test
sed: -e expression #1, char 1: unknown command: `_'
$
$ sed '/this/s/^/added/g' test
addedthis
that
addedthis
orthat
addedorthis
$
$ sed '?this?s?^?added?g' test
sed: -e expression #1, char 1: unknown command: `?'
$

]]>
By: Berserk9779 https://backreference.org/2010/02/20/using-different-delimiters-in-sed/#comment-25103 Wed, 02 Jul 2014 18:15:00 +0000 http://backreference.org/?p=8#comment-25103 Not any character will do, only single byte ones:

sed -i 'sñasdñfghñg' tt
sed: -e expression #1, char 2: delimiter character is not a single-byte character

]]>
By: Johan Hedberg https://backreference.org/2010/02/20/using-different-delimiters-in-sed/#comment-25101 Tue, 17 Jun 2014 14:46:15 +0000 http://backreference.org/?p=8#comment-25101 In reply to waldner.

Did a test on Solaris and on Sun sed the backslash doesn't work. However with GNU sed it works. So for compability one shouldn't use backslash.

root@solaris11:~# echo abc | sed 's\b\B\'
abc
root@solaris11:~# echo abc | gsed 's\b\B\'
aBc
]]>