2 command-line text-processing
这是我输入的内容和得到的输出:
$ cat helloworld.txt
Hello World!
I'm Kanladaporn Sirithatthamrong
6480952
Run Code Online (Sandbox Code Playgroud)
但这就是我想要的输出:
Hello World!
I'm Kanladaporn Sirithatthamrong
6480952
Run Code Online (Sandbox Code Playgroud)
我应该怎么办?请问有什么建议吗?
Jos*_*Jos 10
使用pr
:
$ pr -Td helloworld.txt
Hello World!
I'm Kanladaporn Sirithatthamrong
6480952
$
Run Code Online (Sandbox Code Playgroud)
从man pr
:
-d, --double-space
double space the output
-T, --omit-pagination
omit page headers and trailers, eliminate any pagination by form feeds set in input files
Run Code Online (Sandbox Code Playgroud)
您可以使用sed
:
sed G helloworld.txt
Run Code Online (Sandbox Code Playgroud)
要仅在还没有空行时添加换行符,请使用:
sed '/^$/d;G' helloworld.txt
Run Code Online (Sandbox Code Playgroud)
参考:SED 的便捷单线
归档时间: |
|
查看次数: |
1248 次 |
最近记录: |