## Generate the samples list # go to the Data directory cd ../Data # subtitute "_L00" and any following character by nothing ls Raw_Data | sed 's/_L00.*//' | uniq > samples.txt ## Generate the paths to the fastq files divided by samples # make directory to hold the lists mkdir -p fastq_lists # for each sample while read -r sample do # extract the fastq names from that sample and separate the lanes by comas ls -d $(pwd)/Raw_Data/* | grep $sample | grep R1 | sed -z 's/\n/,/g;s/,$/\n/' \ > fastq_lists/${sample}_R1.csv ls -d $(pwd)/Raw_Data/* | grep $sample | grep R2 | sed -z 's/\n/,/g;s/,$/\n/' \ > fastq_lists/${sample}_R2.csv # create a single file with both R1 and R2 (separate by space) # paste -d " " fastq_lists/${sample}_R2.csv fastq_lists/${sample}_R1.csv \ # > fastq_lists/${sample}.csv # tidy up removing the intermediate files # rm fastq_lists/*{R1,R2}.csv done < samples.txt