Shell脚本随机无法执行文件操作命令

时间:2013-12-07 23:10:13

标签: linux shell unix ubuntu-10.04 bioinformatics

我在运行此脚本时遇到了一些麻烦。时不时地,它将无法执行下面引用的mv命令或rm命令。然后下一次迭代将感受到失败的全部影响。为什么会发生这种情况,我该如何控制呢?作为参考,语法phyml -i $f [parameters]将文件$f_phyml_tree.txt$f_phyml_stats.txt输出到与$f相同的目录中。我希望将这些文件从该目录中取出,同时将树保存在其他地方。

ber="_phyml_tree.txt"
for f in ~/randseqs/aa/*.txt;
do
    echo $f
    fpath=`echo $f | cut -d'/' -f 6`
    if [ ! -f /home/mcb3421_10/phymlout/aa/$fpath$ber ] || [ ! -f /home/mcb3421_10/phymltimer/aa/$fpath ]; then
        phyml -i $f -d aa -b 0 -m Blosum62 > ~/blown.txt
        grep "Time used" < ~/blown.txt > ~/phymltimer/aa/$fpath
        mv /home/mcb3421_10/randseqs/aa/*$ber phymlout/aa
        if [ ! -f /home/mcb3421_10/phymlout/aa/$fpath$ber ]; then
            echo $f failed to write, check the logfile /home/mcb3421_10/phymllogs/aa/$fpath
        fi
        rm ~/randseqs/aa/*_stat*
        mv ~/blown.txt ~/phymllogs/aa/$fpath
    fi
done
for f in ~/randseqs/nuc/*.txt;
do
    echo $f
    fpath=`echo $f | cut -d'/' -f 6`
    if [ ! -f /home/mcb3421_10/phymlout/nuc/$fpath$ber ] || [ ! -f /home/mcb3421_10/phymltimer/nuc/$fpath ]; then
        phyml -i $f -d nt -b 0 -m HKY85 > ~/blown.txt
        grep "Time used" < ~/blown.txt > ~/phymltimer/nuc/$fpath
        mv /home/mcb3421_10/randseqs/nuc/*$ber phymlout/nuc
        if [ ! -f /home/mcb3421_10/phymlout/nuc/$fpath$ber ]; then
            echo $f failed to write, check the logfile /home/mcb3421_10/phymllogs/nuc/$fpath
        fi
        rm ~/randseqs/nuc/*_stat*
        mv ~/blown.txt ~/phymllogs/nuc/$fpath
    fi
done

0 个答案:

没有答案