这个例子中的-i
和-t
是什么
ls . | xargs -i -t cp ./{} $1
我知道这是将当前目录中的所有内容复制到传入的参数 ($1
) 中,但我不明白什么是 -i
和 -t
确实如此。
the example above is a snippet in a bash script file in case you are wondering of the "argument.
最佳答案
来自 man xargs
:
-I replace-str Replace occurrences of replace-str in the initial-arguments with names read from standard input. Also, unquoted blanks do not terminate input items; instead the separator is the newline character. Implies -x and -L 1. -i[replace-str], --replace[=replace-str] This option is a synonym for -Ireplace-str if replace-str is specified. If the replace-str argument is missing, the effect is the same as -I{}. This option is deprecated; use -I instead. -t, --verbose Print the command line on the standard error output before executing it.
在您的例子中,-i
后面没有 replace-str,因此可以将其视为 -I{}
。这意味着 cp ./{} $1
中的 {}
被替换为每个要复制的文件名。
关于linux - 了解 xargs 选项 -i 和 -t,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56104719/