问题
Lets say i have a text:
"this\n is >\n<"
and i want to replace the newline with none which will result in:
"this\n is ><"
How to achieve this ?
i tried using the following:
echo "this\n is >\n<" | sed -e 's/>\n<//g'
But it didn't work out. Any help would be appreciated.
回答1:
Escape \
with \
:
echo "this\n is >\n<" | sed -e 's/>\\n</></g'
Output:
this\n is ><
来源:https://stackoverflow.com/questions/38422453/how-to-replace-just-one-newline-between-and-in-unix