I have a problem with a bash script I am trying to use. I have a directory with 1000s of files and I want to run a command sequentially using each file. However, each file is paired with another, e.g File1.sam, File1.gz, File2.sam, File2.gz etc.. and the command I am executing requires that I use both files from a pair as arguments. I have been using something similar to the command below when only a single argument was required, and I thought (wrongly) that I could just simply extend it like below.
shopt -s nullglob
for myfile1 in *.sam && for myfile2 in *.gz
do
./bwa samse -r "@RG\tID:$myfile1\tLB:$myfile1\tSM:$myfile1\tPL:ILLUMINA" lope_V1.2.fasta $myfile1 $myfile2 > $myfile1.sam2 2>$myfile1.log
done
Anyone know how I can modify this or point me in the direction of another way of doing it?