I have a very basic question, but I can't get a solution. I have multiple files in the same directory and I would like to concatenate each pair of files. The names are:
Sample1_R1_L001.fastq Sample1_R2_L001.fastq Sample2_R1_L001.fastq Sample2_R2_L001.fastq Sample3_R1_L001.fastq Sample3_R2_L001.fastq
(etc...)
The result I want is to concatenate by sample, such as cat Sample1_R1_L001.fastq Sample1_R2_L001.fastq > Sample1_concat.fastq
I tried this loop, find . -name "_R?_"|while read file; do "$file"R1*.fastq "$file"_R2_L001.fastq > "$file"_merged.fastq
but it didn't work. Any thoughts?