How to replace just one newline between > and < in unix

爷,独闯天下 提交于 2019-12-31 07:32:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!