我想编写一个shell脚本,它读取文件并使用该文件的列作为perl脚本的输入。 perl脚本遍历文件(number1,number2),提取ID并将其写入新文件。如果我在命令行中使用它,perl脚本工作正常,但是,我的问题是如何编写shell脚本以使用我的input_file中的变量作为perl脚本。
我的input_file看起来像
number1 ID1
number2 ID2
我使用以下shell脚本(不起作用,所以请帮忙)
#!/bin/bash
input_file="$1"
while IFS=" " read -r number ID
do
perl extract.pl $ID $number.ext > $number_ID.ext
done < "$1"
更换
$number_ID.ext
同
${number}_ID.ext
_
是变量名中允许的字符。这就是为什么bash正在寻找$number_ID
。 .
不被允许。