如何只替换>之间的一个换行符和<在Unix中 [英] How to replace just one newline between > and < in unix

查看:126
本文介绍了如何只替换>之间的一个换行符和<在Unix中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我说说我的话:

"this\n is >\n<"

并且我想用不替换换行符,这将导致:

and i want to replace the newline with none which will result in:

"this\n is ><"

如何实现这一目标?

我尝试使用以下内容:

echo "this\n is >\n<" | sed -e 's/>\n<//g'

但是没有成功.任何帮助将不胜感激.

But it didn't work out. Any help would be appreciated.

推荐答案

\转义\:

echo "this\n is >\n<" | sed -e 's/>\\n</></g'

输出:

this\n is ><

这篇关于如何只替换&gt;之间的一个换行符和&lt;在Unix中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆