linux - 了解 xargs 选项 -i 和 -t

标签 linux bash shell xargs

这个例子中的-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/

相关文章:

用于合并目录中的文件并删除原件的 Bash 脚本

linux - 如何授予 Nagios 权限以在自定义脚本中运行某些命令?

linux - (Mac) 将核心文件留在可执行文件所在的位置而不是/cores?

linux - 获取 sed 以用参数替换文本

Python 脚本仅使用 "python"命令运行

bash: ????: 找不到命令

python - 如何从 Shell 捕获错误并重新启动 Python

linux - Linux 内核 header 中的错误

linux - 将数字转换为千兆字节(sed、awk、sh、bash)

c - 增加标准输出缓冲区大小