我有以下for循环:
for p in 3UTR 5UTR coding_genic genic non_synonymous reg synonymous
do
for i in 1 2 3
do
qsub compute.job -v VAR1="$i", VAR2="$p"
done
done
因此在另一个for循环中嵌入了一个for循环。目标是运行“qsub”命令(将作业提交到集群计算机),其中“compute.job”中的“VAR1”变量替换为1,2或3,并且“VAR2”变量替换为由p。
表示的字符串之一这部分工作正常:
for i in 1 2 3
do
qsub compute.job -v VAR1="$i", VAR2="$p"
done
但是添加另一个for循环不会......关于这里可能出错的任何想法? (我怀疑它与琴弦有关......)
非常感谢!
答案 0 :(得分:2)
我怀疑逗号后面不应该有空格:
qsub compute.job -v VAR1="$i",VAR2="$p"
实际的p和i变量设置完好,我用回声检查。
答案 1 :(得分:1)
什么不起作用?
$ cat ff
for p in 3UTR 5UTR coding_genic genic non_synonymous reg synonymous
do
for i in 1 2 3
do
echo "qsub compute.job -v VAR1=\"$i\", VAR2=\"$p\""
done
done
$ ./ff
qsub compute.job -v VAR1="1", VAR2="3UTR"
qsub compute.job -v VAR1="2", VAR2="3UTR"
qsub compute.job -v VAR1="3", VAR2="3UTR"
qsub compute.job -v VAR1="1", VAR2="5UTR"
qsub compute.job -v VAR1="2", VAR2="5UTR"
qsub compute.job -v VAR1="3", VAR2="5UTR"
qsub compute.job -v VAR1="1", VAR2="coding_genic"
qsub compute.job -v VAR1="2", VAR2="coding_genic"
qsub compute.job -v VAR1="3", VAR2="coding_genic"
qsub compute.job -v VAR1="1", VAR2="genic"
qsub compute.job -v VAR1="2", VAR2="genic"
qsub compute.job -v VAR1="3", VAR2="genic"
qsub compute.job -v VAR1="1", VAR2="non_synonymous"
qsub compute.job -v VAR1="2", VAR2="non_synonymous"
qsub compute.job -v VAR1="3", VAR2="non_synonymous"
qsub compute.job -v VAR1="1", VAR2="reg"
qsub compute.job -v VAR1="2", VAR2="reg"
qsub compute.job -v VAR1="3", VAR2="reg"
qsub compute.job -v VAR1="1", VAR2="synonymous"
qsub compute.job -v VAR1="2", VAR2="synonymous"
qsub compute.job -v VAR1="3", VAR2="synonymous"