I am using below regex in my script to read files ending of type _L001_R1_001.fastq or _L001_R2_001.fastq
if it is R1 it should be read into readPair_1 and if R2 it should be read into readPair_2 but its not matching anything.
can anyone please tell me what is wrong here?
My script:
#! /bin/bash -l
Proj_Dir="${se_ProjDir}/*.fastq"
for Dir in $Proj_Dir
do
if [[ "$Dir" =~ _L.*_R1_001.fastq]]
then
readPair_1=$Dir
echo $readPair_1
fi
if [[ "$Dir" =~ _L.*_R2_001.fastq]]
then
readPair_2=$Dir
echo $readPair_2
fi
Files:
Next-ID-1-MN-SM5144-170509-ABC_S1_L001_R1_001.fastq
Next-ID-1-MN-SM5144-170509-ABC_S1_L001_R2_001.fastq
Next-ID-1-MN-SM5144-170509-ABC_S2_L001_R1_001.fastq
Next-ID-1-MN-SM5144-170509-ABC_S2_L001_R2_001.fastq
Next-ID-1-MN-SM5144-170509-ABC_S3_L001_R1_001.fastq
Next-ID-1-MN-SM5144-170509-ABC_S3_L001_R2_001.fastq
_L[^_]*_R[0-9]+_001\.fastq\.gz. A$at the end might also be useful to match only at the end of input..s but it looks like it should still match the R1_001 files.