linux - 具有多个参数的 xargs

标签 linux bash shell command-line-arguments xargs

我有一个源输入,input.txt

a.txt
b.txt
c.txt

我想将这些输入输入到程序中,如下所示:

my-program --file=a.txt --file=b.txt --file=c.txt

所以我尝试使用 xargs,但没有成功。

cat input.txt | xargs -i echo "my-program --file"{}

它给了

my-program --file=a.txt
my-program --file=b.txt
my-program --file=c.txt

但我想要

my-program --file=a.txt --file=b.txt --file=c.txt

有什么想法吗?

最佳答案

不要听所有人的。 :) 看看这个例子:

echo argument1 argument2 argument3 | xargs -l bash -c 'echo this is first:$0 second:$1 third:$2'

输出将是:

this is first:argument1 second:argument2 third:argument3

关于linux - 具有多个参数的 xargs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3770432/

相关文章:

linux - Rgd 文件用 Null 替换单引号

php - 如果 $arr1 和 $arr2 的元素具有相同的值,有没有办法合并 array_count_values($arr1) 和 array_count_values($arr2) 的结果?

bash - 仅按月份名称和日期排序。狂欢

linux - 协议(protocol) 2 主机 key 算法错误 '+ssh-dss'

macos - Mac OS X - 将带有空格的路径名作为参数传递给 bashscript,然后发出打开终端命令

linux - Bash if 语句适用于一种情况而不适用于其他情况

linux - 帮助查找和替换字符串的 Shell 脚本

linux - Kubernetes Pod 报告的内存使用量多于实际进程消耗量

linux - Google Compute Engine 实例需要 sudo 密码 - 我的密码是什么?

c - 后台进程和挂起进程 - 在 C 中实现作业控制 Shell