sed
does not support the
escape sequence in its substitution command, however, it does support a real newline character if you escape it (because sed
commands should only use a single line, and the escape is here to tell sed
that you really want a newline character):
$ sed 's/),(/),\
(/g' temp.txt
(foo),
(bar)
(foobar),
(foofoobar)
You can also use a shell variable to store the newline character.
$ NL='
'
$ sed "s/),(/,\$NL(/g" temp.txt
(foo),
(bar)
(foobar),
(foofoobar)
Tested on Mac OS X Lion, using bash
as shell.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…