sed help:匹配并替换文字"\ n" (不是换行符) [英] sed help: matching and replacing a literal "\n" (not the newline)
本文介绍了sed help:匹配并替换文字"\ n" (不是换行符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件,其中包含 \ n 的多个实例.
i have a file which contains several instances of \n.
我想用实际的换行符替换它们,但sed无法识别 \ n .
i would like to replace them with actual newlines, but sed doesn't recognize the \n.
我尝试过
sed -r -e 's/\n/\n/'
sed -r -e 's/\\n/\n/'
sed -r -e 's/[\n]/\n/'
以及其他多种转义方法.
and many other ways of escaping it.
sed是否能够识别文字 \ n ?如果可以,怎么办?
is sed able to recognize a literal \n? if so, how?
还有另一个程序可以读取将 \ n 解释为真实换行符的文件吗?
is there another program that can read the file interpreting the \n's as real newlines?
推荐答案
可以请尝试一下
sed -i 's/\\n/\n/g' input_filename
这篇关于sed help:匹配并替换文字"\ n" (不是换行符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文