最后一次完成错误,阻止在bash中进一步处理



下面的bash似乎在最后一个done上出错了。什么是正确的语法,因为我似乎不能弄清楚它没有创造更多的错误。之后还有一些额外的进程将不会运行,因为当前抛出了一个错误。谢谢。

误差

/home/cmccabe/Desktop/loop.sh: line 79: syntax error near unexpected token `done'
/home/cmccabe/Desktop/loop.sh: line 79: `done >> "$logfile"'
bash

logfile=/home/cmccabe/Desktop/NGS/API/6-2-2016/process.log
for file in /home/cmccabe/Desktop/NGS/API/6-2-2016/vcf/overall/stats/*.vcf ; do
 echo "Start annovar creation: $(date) - file: $file"
 echo ${file##*/} >> /home/cmccabe/Desktop/NGS/annovar/target.txt
cp /home/cmccabe/Desktop/NGS/API/6-2-2016/vcf/overall/stats/*.vcf /home/cmccabe/Desktop/NGS/annovar
 echo "End annovar file creation: $(date) - file: $file"
done
logfile=/home/cmccabe/Desktop/NGS/API/6-2-2016/process.log
cd "/home/cmccabe/Desktop/NGS/annovar"
$( perl -ne 'chomp; system ("perl table_annovar.pl -vcfinput $_ humandb/ -buildver hg19 -arg '-hgvs',,,,,,,,,, -remove -protocol IDP.refGene,avsnp147,popfreq_all_20150413,spidex,ljb26_sift,ljb26_pp2hdiv,ljb26_pp2hvar,ljb26_lrt,ljb26_mt,ljb26_ma,clinvar_20160302 -operation g,f,f,f,f,f,f,f,f,f,f")' < target.txt )
mv /home/cmccabe/Desktop/NGS/annovar/*multianno.txt /home/cmccabe/Desktop/NGS/API/6-2-2016/vcf/overall/annovar
  echo "End annovar annotation creation: $(date) - file: $file"
done >> "$logfile"

您希望>>位于echo行,就像这样。done也是多余的;没有需要关闭的循环:

logfile=/home/cmccabe/Desktop/NGS/API/6-2-2016/process.log
cd "/home/cmccabe/Desktop/NGS/annovar"
$( perl -ne 'chomp; system ("perl table_annovar.pl -vcfinput $_ humandb/ -buildver hg19 -arg '-hgvs',,,,,,,,,, -remove -protocol IDP.refGene,avsnp147,popfreq_all_20150413,spidex,ljb26_sift,ljb26_pp2hdiv,ljb26_pp2hvar,ljb26_lrt,ljb26_mt,ljb26_ma,clinvar_20160302 -operation g,f,f,f,f,f,f,f,f,f,f")' < target.txt )
mv /home/cmccabe/Desktop/NGS/annovar/*multianno.txt /home/cmccabe/Desktop/NGS/API/6-2-2016/vcf/overall/annovar
  # See here
echo "End annovar annotation creation: $(date) - file: $file" >> "$logfile"

最新更新