文本每行的某列作为参数传递给别的程序
我有一个程序 test.pl要求输入两个参数,所有的参数存在于另一个文件的第二第三列,我怎么才能实现让文本每行的第2、3列作为参数调用这个程序呢?
比如参数文本是:
1 a.txt b.txt
2 a.txt c.txt
想实现
perl test.pl a.txt b.txt
perl test.pl a.txt c.txt
1 -------------------------------------------------------------------------------------- 2 awk '{system("perl test.pl "$2" "$3)}' file 3 ----------------------------------------------------------------------- 4 cat file | awk '{print $2,$3}' | xargs -I'{}' perl test.pl '{}' 5 ----------------------------------------------------------------------- 6 awk '{system("perl test.pl "$2$FS$3)}' file 7 sed -nr 's/([^ ]+)\s*([^ ]+)\s*([^ ]+)$/perl test.pl \2 \3/p' file| sh