我有一个包含如下内容的txt文件:
Some random
text here. This file
has multiple lines. Should be one line.
我使用:
sed '{:q;N;s/\n/:sl:/g;t q}' file1.txt > singleline.txt
并获得:
Some random:sl:text here. This file:sl:has multiple lines. Should be one line.
现在我想将
:sl:
模式替换为换行符(\n)
。当我使用以下代码时:sed 's/:sl:/&\n/g' singleline.txt
I get:
Some random:sl:
text here. This file:sl:
has multiple lines. Should be one line.
如何将模式替换为换行符,而不是在模式后添加换行符?
sed 's/:sl:/\n/g' singleline.txt
- Avinash Raj