如何在Bash中调用任意数量的参数,而不使用eval和字符串连接

如何在Bash中调用任意数量的参数,而不使用eval和字符串连接,bash,shell,Bash,Shell,我想编写一个调用命令的脚本,该命令返回一个表,我需要使用该信息调用第二个命令作为参数。不需要字符串连接和求值就可以实现吗 例1 $ command1 inputfile 1: 1 2 3 2: 6 10 20 $ command2 -a 1 -b 2 -c 3 file1 -a 6 -b 10 -c 20 file2 例2 $ command1 inputfile 1: 1 2 3 2: 6 10 20 3: 7 8

我想编写一个调用命令的脚本,该命令返回一个表,我需要使用该信息调用第二个命令作为参数。不需要字符串连接和求值就可以实现吗

例1

$ command1 inputfile
1:    1    2    3
2:    6   10   20
$ command2 -a 1 -b 2 -c 3 file1 -a 6 -b 10 -c 20 file2
例2

$ command1 inputfile
1:    1    2    3
2:    6   10   20
3:    7    8    4
$ command2 -a 1 -b 2 -c 3 file1 -a 6 -b 10 -c 20 file2 -a 7 -b 8 -c 4 file3

#/bin/bash
args=()
读取filenum parm1 parm2 parm3时
做
args+=(-a“$parm1”-b“$parm2”-c“$parm3”文件${filenum%:}”)
完成<
#!/bin/bash
args=()
while read filenum parm1 parm2 parm3
do
  args+=(-a "$parm1" -b "$parm2" -c "$parm3" "file${filenum%:}")
done < <(command1 inputfile)
command2 "$args[@]"