How do I insert a newline in the replacement part of sed?
This code isn\'t working:
sed \"s/\\(1234\\)/\\n\\1/g\" input.txt > output.txt
>
The solaris version of sed
I could convince to work this way (in bash
):
echo test1234foo123bar1234 | sed 's/\(1234\)/\
\1/g'
(you have to put the line break directly after the backslash).
In csh
I had to put one more backslash:
echo test1234foo123bar1234 | sed 's/\(1234\)/\\
\1/g'
The Gnu version of sed
simply worked using \n
:
echo test1234foo123bar1234 | sed 's/\(1234\)/\n\1/g'