Hi all,
I'm relatively new to bash scripting and working on one to map samples with BWA bash-loop.

My loop is the following:


    for i in $(ls *.fastq.gz | rev | cut -c 10- | rev | uniq)
    do

     ./bwa mem -t 60 -c 1 -R '@RG\tID:${i}\tSM:${i}\tPL:illumina\tPU:Lane1\tLB:exome' MyReference.fq ${i}.fastq.gz ${i}.fastq.gz > ${i}.sam
     done

The '-R' flag will add the read group info into the sam file. I am having trouble with having the actual sample name being added, rather than it just printed with a '${i}'. I've spending lot's of time googling, and trying to figure this out, but haven't been able to yet. Any advice would be appreciated.





Try `"` instead of `'` for quoting. Variable expansion needs double quotes.