xargs 的 -I 标志参数的语法是什么?
What is the syntax for xargs' -I flag argument?
该文档仅用文字模糊地说明了它的作用,我无法在 Internet 上轻松找到任何示例。
那么,如何使用 xargs 的 -I 标志?我知道它与参数命令中的字符串替换有关,但不清楚如何使用它。
来自tldr xargs
:
- Execute the command once for each input line, replacing any occurrences of the placeholder (here marked as `_`) with the input line:
arguments_source | xargs -I _ command _ optional_extra_arguments
所以,像这样:
$ echo "foo" | xargs -I _ echo "bar-"_
bar-foo
xargs
获取输入 foo
,用它替换 _
,而不是打印 bar-_
打印 bar-foo
到控制台