了解 xargs 选项 -i 和 -t

Understanding xargs options -i and -t

这个例子中的-i-t是什么

ls . | xargs -i -t cp ./{} 

我知道这是将当前目录中的所有内容复制到传入的参数 (</code>) 中,但我不明白 <code>-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 ./{} 中的 {} 将替换为要复制的每个文件名。