파일 이름에 특정 문자("rem_trim")가 포함된 파일에 대한 for 루프

파일 이름에 특정 문자("rem_trim")가 포함된 파일에 대한 for 루프

아래 파일에 대해 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

관련 정보