小编yZa*_*aph的帖子

Sed:用“-z”替换换行符?

问题:与替换一些正则表达式\nsed

解决方法:类似的答案有很多[ 1 ][ 2 ][ 3 ][ 4 ],还有很多其他的链接我就不链接了。他们都建议你创建一个新标签:a,合并行N,分支到:aif not end-of-file $!ba,然后执行一些命令。

也就是说...... 在GNU sed手册中,有一个-z选项:

-z
--null-data
--zero-terminated

Treat the input as a set of lines, each terminated by a zero byte
(the ASCII ‘NUL’ character) instead of a newline. This option can
be used with commands like ‘sort -z’ and ‘find -print0’ to process
arbitrary file names. 
Run Code Online (Sandbox Code Playgroud)

因此,首先,出于比较原因,如果我们尝试幼稚的方法:

$ seq 3 | sed 's/\n/ /g' …
Run Code Online (Sandbox Code Playgroud)

sed

4
推荐指数
1
解决办法
1810
查看次数

标签 统计

sed ×1