Insert text at start/end of line

Aug 23, 2010
619
9
'[' and ']' have not been used in a regexp in this thread.
This too.

Code:
vefatica@jj:~$ echo foo | sed -e 's/.*/prefix \0 postfix/g'
prefix foo postfix
vefatica@jj:~$ echo foo | sed -e 's/.*/[[ \0 ]]/g'
[[ foo ]]

But it gets all fouled up when I try to use it from windows. Below, the second is expected; the first seems wacky.

Code:
v:\> echo foo | (wsl sed -e 's/.*/[[ \0 ]]/g')
 ]]foo

v:\> echo foo | (wsl sed -e 's/.*/[[ \\0 ]]/g')
[[ \0 ]]
 
May 20, 2008
11,046
90
Syracuse, NY, USA
In

Code:
echo foo | sed -e 's/.*/[[ \0 ]]/g'

Code:
[[ \0 ]]

is not a regular expression. It is a replacement string (containing a reference to another string). '[' and ']' are not special there.
 
Thread starter Similar threads Forum Replies Date
Charles Dye T&T - TPIPE 0
Charles Dye T&T - TPIPE 1