xargs为何换行了

sh/bash/dash/ksh/zsh等Shell脚本
回复
whaha
帖子: 104
注册时间: 2016-07-08 17:43
系统: debian8

xargs为何换行了

#1

帖子 whaha » 2016-12-24 20:45

-0
: 当输入有特殊字符时,将其当作一般字符处理.
test@hwy:~$ echo "//" | xargs -0
//

test@hwy:~$

为何出现换行?
科学之子
帖子: 2284
注册时间: 2013-05-26 6:58
系统: Debian 9

Re: xargs为何换行了

#2

帖子 科学之子 » 2016-12-24 21:11

man xargs
-0 Input items are terminated by a null character instead of by whitespace, and the quotes and backslash are not special (every character is taken literally).
Disables the end of file string, which is treated like any other argument. Useful when input items might contain white space, quote marks, or backslashes. The
GNU find -print0 option produces input suitable for this mode.
"特殊字符"应该指的是特殊的普通字符,像转义字符,双引号之类
头像
lilydjwg
论坛版主
帖子: 4249
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: xargs为何换行了

#3

帖子 lilydjwg » 2016-12-24 22:23

and executes the command (default is /bin/echo)
第一个换行来自于你的 echo 调用(你可以用 echo -n 这样就没了),第二个来自于 xargs 调用的 echo。
回复