find . -type f -print
Run Code Online (Sandbox Code Playgroud)
打印出来
./file1
./file2
./file3
Run Code Online (Sandbox Code Playgroud)
任何方式使其打印
file1
file2
file3
Run Code Online (Sandbox Code Playgroud)
?
(虽然分词在 Bash 中有一个特定的定义,但在这篇文章中它的意思是在空格或制表符上进行拆分。)
使用此输入向 xargs 演示问题,
$ cat input.txt
LineOneWithOneArg
LineTwo WithTwoArgs
LineThree WithThree Args
LineFour With Double Spaces
Run Code Online (Sandbox Code Playgroud)
和这个 Bash 命令回显传递给它的参数,
$ bash -c 'IFS=,; echo "$*"' arg0 arg1 arg2 arg3
arg1,arg2,arg3
Run Code Online (Sandbox Code Playgroud)
注意如何xargs -L1将每行单词拆分为多个参数。
$ xargs <input.txt -L1 bash -c 'IFS=,; echo "$*"' arg0
LineOneWithOneArg
LineTwo,WithTwoArgs
LineThree,WithThree,Args
LineFour,With,Double,Spaces
Run Code Online (Sandbox Code Playgroud)
但是,xargs -I{}将整行扩展{}为单个参数。
$ xargs <input.txt -I{} bash -c 'IFS=,; echo "$*"' arg0 {}
LineOneWithOneArg
LineTwo WithTwoArgs
LineThree WithThree Args
LineFour With …Run Code Online (Sandbox Code Playgroud)