简体   繁体   English

使用-0和xargs

[英]Using -0 with xargs

I am trying to give an input to xargs that is NUL separated. 我试图给NUL分离的xargs一个输入。 To this effect I have this: 为此,我有这个:

$ echo -n abc$'\000'def$'\000' | xargs -0 -L 1

I get 我明白了

abcdef

I wonder why doesn't it print o/p as 我想知道为什么它不打印o / p

abc
def

Your main problem is that you forgot -e : 你的主要问题是,你忘了-e

$ echo -n abc$'\000'def$'\000' |cat -v
abcdef

No zero bytes are seen. 没有看到零字节。 But this: 但是这个:

$ echo -en abc'\000'def'\000' |cat -v
abc^@def^@

is more like it, the ^@ is how cat -v shows a zero byte. 更像是, ^@cat -v显示零字节的方式。 And now for xargs : 现在对于xargs

$ echo -en abc'\000'def'\000' | xargs -0 -L 1
abc
def

Try help echo from your bash prompt. 尝试从bash提示符中获取help echo

尝试将输入视为单引号字符串。

echo -ne "abc\0def\0" | xargs -0 -L 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM