gpt4 book ai didi

linux - 重击 : doubly looping don't work

转载 作者:太空宇宙 更新时间:2023-11-04 05:15:58 26 4
gpt4 key购买 nike

我有这个循环,但它不起作用:-/

for i in *CCDSxBaseCov.bed
do SM=`(echo $i | sed 's/.bed//g')`; echo $SM
for chr in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y M; do echo "-- chr$chr --"; bases=`(grep chr$chr "${SM}_hg19_EXONSxBaseCov.bed" | wc -l)`; echo "EXONS target length=$bases"; cov=`(grep chr$chr "${SM}_hg19_EXONSxBaseCov.bed" | awk '{sum+=$3} END {print sum}')`; echo "sum EXONS bases coverage=$cov"; avercov=$(($cov/$bases)); echo "EXONS average coverage=$avercov" >> ${SM}_hg19_EXONScovstats.txt
done
done

第二个循环单独工作

最佳答案

注释内部 for(如果它可以独立工作)并屏蔽 $i,因为它是一个文件名,可能包含空格。使用 $(...) 代替已弃用的反引号。

for i in *CCDSxBaseCov.bed
do SM=$((echo "$i" | sed 's/.bed//g')); echo $SM
# for chr in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X Y M; do echo "-- chr$chr --"; bases=`(grep chr$chr "${SM}_hg19_EXONSxBaseCov.bed" | wc -l)`; echo "EXONS target length=$bases"; cov=`(grep chr$chr "${SM}_hg19_EXONSxBaseCov.bed" | awk '{sum+=$3} END {print sum}')`; echo "sum EXONS bases coverage=$cov"; avercov=$(($cov/$bases)); echo "EXONS average coverage=$avercov" >> ${SM}_hg19_EXONScovstats.txt
# done
done

关于linux - 重击 : doubly looping don't work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49339941/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com