我得到这个意外的“完成”标记错误意外令牌“完成”的错误在for循环shell脚本
echo -e "Enter the file stem name"
read filestem
for i in {1..22}
do
`java -cp /export/home/alun/jpsgcs/ CMorgansToTheta $filestem_$i.INPUT.par $filestem_$i.THETA.par`
done
我得到这个意外的“完成”标记错误意外令牌“完成”的错误在for循环shell脚本
echo -e "Enter the file stem name"
read filestem
for i in {1..22}
do
`java -cp /export/home/alun/jpsgcs/ CMorgansToTheta $filestem_$i.INPUT.par $filestem_$i.THETA.par`
done
在你的Java命令行:
java -cp /export/home/alun/jpsgcs/ CMorgansToTheta $filestem_$i.INPUT.par $filestem_$i.THETA.par
您正在使用:
$filestem_$i
这将是相当于:
${filestem_}${i}
,因为下划线_
不被视为shell中的字边界,整个filestem_
将被视为变量名称。最有可能你应该使用:
${filestem}_${i}
你能告诉我这个脚本的输出?
#!/bin/bash
set -x
echo -e "Enter the file stem name"
read filestem
for i in {1..3}
do
echo "java -cp /export/home/alun/jpsgcs/ CMorgansToTheta ${filestem}_${i}.INPUT.par ${filestem}_${i}.THETA.par"
done
如果Java程序没有写入到输出,你for
循环相当于(因为反引号的)到
for i in {1..22}
do
done
它会产生你看到的错误。很可能你只是想删除反引号来运行程序22时间:
echo -e "Enter the file stem name"
read filestem
for i in {1..22}
do
java -cp /export/home/alun/jpsgcs/ CMorgansToTheta "${filestem}_$i.INPUT.par" "${filestem}_$i.THETA.par"
done
您是否尝试在脚本的顶部添加'#!/ bin/bash'标头? –
为什么在反引号中有'java -cp ..'?没有任何意义,除非你将java命令输出到某个变量。 – 2013-06-18 17:21:44
或删除反引号?该java程序是否真的返回可执行'bash'语句? –