Using -0 with xargs
I am trying to give an input to xargs that is NUL separated. To this eff开发者_StackOverflow中文版ect 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
abc
def
Your main problem is that you forgot -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. And now for xargs:
$ echo -en abc'\000'def'\000' | xargs -0 -L 1
abc
def
Try help echo from your bash prompt.
Try treating the input as a single quoted string.
echo -ne "abc\0def\0" | xargs -0 -L 1
加载中,请稍侯......
精彩评论