将 -0 与 xargs 一起使用
我正在尝试向 xargs 提供以 NUL 分隔的输入。为此,我有这样的:
$ echo -n abc$'\000'def$'\000' | xargs -0 -L 1
我想
abcdef
知道为什么它不将 o/p 打印为
abc
def
I am trying to give an input to xargs that is NUL separated. To this effect I have this:
$ echo -n abc
I get
abcdef
I wonder why doesn't it print o/p as
abc
def
\000'def
I get
I wonder why doesn't it print o/p as
\000' | xargs -0 -L 1
I get
I wonder why doesn't it print o/p as
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的主要问题是您忘记了
-e
:看不到零字节。但这:
更像是,
^@
是cat -v
显示零字节的方式。现在对于xargs
:在 bash 提示符下尝试
help echo
。Your main problem is that you forgot
-e
:No zero bytes are seen. But this:
is more like it, the
^@
is howcat -v
shows a zero byte. And now forxargs
:Try
help echo
from your bash prompt.尝试将输入视为单引号字符串。
Try treating the input as a single quoted string.