我有一个源输入,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/