我想获取 bash 命令的输出(在本例中为 grep)并每隔一行插入一个空行:
not
like
this ...
but
like
this!
Run Code Online (Sandbox Code Playgroud)
在 bash 中做到这一点的聪明方法?
使用pr自coreutils:
$ grep '' file | pr -Td
not
like
this ...
Run Code Online (Sandbox Code Playgroud)
(请注意,这会在最后一行加倍空格 - 不像,比如说,sed '$!G')。来自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)
| 归档时间: |
|
| 查看次数: |
5533 次 |
| 最近记录: |