for 循环用于文件名中包含特定字符(“rem_trim”)的文件

for 循环用于文件名中包含特定字符(“rem_trim”)的文件

我想对下面的文件进行 for 循环,但仅限于包含“雷姆修剪名称中的“。刚刚修剪过的已经完成了。

这适用于具有修剪但不具有 rem_trim 的文件

list=`for i in *trim*.1.fq; do echo $i | cut -f 1 -d \. | uniq ; done`
for i in $list; do fastqc $i.1.fq ; fastqc $i.2.fq; done

这就是我一直在尝试对“rem_trim”文件执行的操作:

list=`for i in *rem_trim*.1.fq; do echo $i | cut -f 1 -d \. | uniq ; done`
for i in $list; do fastqc $i.1.fq ; fastqc $i.2.fq; done

文件:

sample_AACCA.rem_trim.1.fq       sample_ACTGG_trim.2_fastqc.html  sample_CTGCG_trim.1_fastqc.html  sample_GCATG_trim.2.fq           sample_GGTTG_trim.1.fq           sample_TCACG.rem_trim.2.fq
sample_AACCA.rem_trim.2.fq       sample_ACTGG_trim.2_fastqc.zip   sample_CTGCG_trim.1_fastqc.zip   sample_GCCGT.rem_trim.1.fq       sample_GGTTG_trim.2_fastqc.html  sample_TCACG_trim.1_fastqc.html
sample_AACCA_trim.1_fastqc.html  sample_ACTGG_trim.2.fq           sample_CTGCG_trim.1.fq           sample_GCCGT.rem_trim.2.fq       sample_GGTTG_trim.2_fastqc.zip   sample_TCACG_trim.1_fastqc.zip
sample_AACCA_trim.1_fastqc.zip   sample_CGAAT.rem_trim.1.fq       sample_CTGCG_trim.2_fastqc.html  sample_GCCGT_trim.1_fastqc.html  sample_GGTTG_trim.2.fq           sample_TCACG_trim.1.fq
sample_AACCA_trim.1.fq           sample_CGAAT.rem_trim.2.fq       sample_CTGCG_trim.2_fastqc.zip   sample_GCCGT_trim.1_fastqc.zip   sample_GTCCG.rem_trim.1.fq       sample_TCACG_trim.2_fastqc.html
sample_AACCA_trim.2_fastqc.html  sample_CGAAT_trim.1_fastqc.html  sample_CTGCG_trim.2.fq           sample_GCCGT_trim.1.fq           sample_GTCCG.rem_trim.2.fq       sample_TCACG_trim.2_fastqc.zip
sample_AACCA_trim.2_fastqc.zip   sample_CGAAT_trim.1_fastqc.zip   sample_GCATG.rem_trim.1.fq       sample_GCCGT_trim.2_fastqc.html  sample_GTCCG_trim.1_fastqc.html  sample_TCACG_trim.2.fq
sample_AACCA_trim.2.fq           sample_CGAAT_trim.1.fq           sample_GCATG.rem_trim.2.fq       sample_GCCGT_trim.2_fastqc.zip   sample_GTCCG_trim.1_fastqc.zip   SE
sample_ACTGG.rem_trim.1.fq       sample_CGAAT_trim.2_fastqc.html  sample_GCATG_trim.1_fastqc.html  sample_GCCGT_trim.2.fq           sample_GTCCG_trim.1.fq
sample_ACTGG.rem_trim.2.fq       sample_CGAAT_trim.2_fastqc.zip   sample_GCATG_trim.1_fastqc.zip   sample_GGTTG.rem_trim.1.fq       sample_GTCCG_trim.2_fastqc.html
sample_ACTGG_trim.1_fastqc.html  sample_CGAAT_trim.2.fq           sample_GCATG_trim.1.fq           sample_GGTTG.rem_trim.2.fq       sample_GTCCG_trim.2_fastqc.zip
sample_ACTGG_trim.1_fastqc.zip   sample_CTGCG.rem_trim.1.fq       sample_GCATG_trim.2_fastqc.html  sample_GGTTG_trim.1_fastqc.html  sample_GTCCG_trim.2.fq
sample_ACTGG_trim.1.fq           sample_CTGCG.rem_trim.2.fq       sample_GCATG_trim.2_fastqc.zip   sample_GGTTG_trim.1_fastqc.zip   sample_TCACG.rem_trim.1.fq

但我明白了:

Skipping 'sample_AACCA.1.fq' which didn't exist, or couldn't be read
Skipping 'sample_AACCA.2.fq' which didn't exist, or couldn't be read
Skipping 'sample_ACTGG.1.fq' which didn't exist, or couldn't be read
Skipping 'sample_ACTGG.2.fq' which didn't exist, or couldn't be read
Skipping 'sample_CGAAT.1.fq' which didn't exist, or couldn't be read
Skipping 'sample_CGAAT.2.fq' which didn't exist, or couldn't be read
Skipping 'sample_CTGCG.1.fq' which didn't exist, or couldn't be read
Skipping 'sample_CTGCG.2.fq' which didn't exist, or couldn't be read
Skipping 'sample_GCATG.1.fq' which didn't exist, or couldn't be read
Skipping 'sample_GCATG.2.fq' which didn't exist, or couldn't be read
Skipping 'sample_GCCGT.1.fq' which didn't exist, or couldn't be read
Skipping 'sample_GCCGT.2.fq' which didn't exist, or couldn't be read
Skipping 'sample_GGTTG.1.fq' which didn't exist, or couldn't be read
Skipping 'sample_GGTTG.2.fq' which didn't exist, or couldn't be read
Skipping 'sample_GTCCG.1.fq' which didn't exist, or couldn't be read
Skipping 'sample_GTCCG.2.fq' which didn't exist, or couldn't be read
Skipping 'sample_TCACG.1.fq' which didn't exist, or couldn't be read
Skipping 'sample_TCACG.2.fq' which didn't exist, or couldn't be read

知道我做错了什么以及什么可能有效吗?谢谢!

答案1

问题是第一组文件的名称中只有一个点,第二组文件的名称中有三个点。

for i in *rem_trim*.1.fq; do echo "${i%.?.fq}" | uniq ; done

为您提供正确的名称部分。

但我不明白为什么你不做得更容易:

for i in *rem_trim*.1.fq; do
    fastqc $i
done
for i in *rem_trim*.2.fq; do
    fastqc $i
done

甚至

for i in *rem_trim*.1.fq *rem_trim*.2.fq; do
    fastqc "$i"
done

相关内容