在父目录中,我有几个子目录,每个子目录都包含一个应该对其执行分析的.vcf.gz文件。我想对所有子目录中的所有.vcf.gz文件运行以下命令。我尝试使用折叠代码,但是结果文件没有保存在相应的子目录中。它保存在主目录中,每次被下一个覆盖时。
find . -type f -name '*.vcf' \
-exec vcftools --gzvcf {} --minGQ 20 --recode --out GENO_FILT_GQ20 ';' \
-exec vcftools --vcf GENO_FILT_GQ20.recode.vcf --max-missing 0.7 --out filtered ';'\
-exec vcftools --vcf GENO_FILT_GQ20.recode.vcf --min-alleles 2 --max-alleles 2 ';'\
-exec /home/bioinformatics/Dokumente/pipeline_test/annovar/convert2annovar.pl \
-format vcf4 GENO_FILT_GQ20.recode.vcf \
-outfile ALL_genepy.input \
-allsample \
-withfreq \
-include 2>annovar.log ';'\
-exec /home/bioinformatics/Dokumente/pipeline_test/annovar/table_annovar.pl \
ALL_genepy.input \
/home/bioinformatics/Dokumente/pipeline_test/annovar/humandb/ \
-buildver hg19 \
-out ALL_genepy \
-remove \
-protocol refGene,gnomad_exome,cadd13,eigen,revel,gwava,dann \
-operation g,f,f,f,f,f,f \
--thread 40 \
--maxgenethread 40 \
-nastring . >>annovar.log';'\
-exec cut -f 18- ALL_genepy.input > a1';'\
-exec zgrep '^#CHR' GENO_FILT_GQ20.recode.vcf | cut -f 10- > b1';'\
-exec cat b1 a1 > ALL_temp';'\
-exec paste ALL_genepy.hg19_multianno.txt ALL_temp > ALL_genepy.meta';'\
-exec rm a1 b1 ALL_temp #remove';'\
-exec mkdir CADD13_RawScore Eigen GWAVA_region_score GWAVA_tss_score dann REVEL ';'\
-exec grep "^Chr" ALL_genepy.meta> header ';'\
-exec chmod +x GENEPY_1.2.sh ';'\
-exec while read gene; do
sh GENEPY_1.2.sh $gene
done < gene.list ';'\
done发布于 2020-11-02 12:31:01
exec运行该命令,它不是“语法感知的”,也不是特殊的。如果你写:
find blabla -exec blabla 2>something ';' -exec blabla >something ';'重定向是由shell 解析的,而不是由find解析的。这和:
find blabla -exec blabla ';' -exec blabla ';' 2>something >something
^^^^^^^^^^^^^^^^^^^^^^ - redirections
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - the command with argumnets丢弃所有的exec,只需执行一个while循环:
find blabla |
while IFS= read -r f; do
: use "$f" here
done阅读https://mywiki.wooledge.org/BashFAQ/001并使用http://shellcheck.net检查脚本
https://stackoverflow.com/questions/64645101
复制相似问题