W
W
wolverine7772020-04-27 01:18:24
linux
wolverine777, 2020-04-27 01:18:24

How to get rid of the backslash if it is immediately followed by an underscore?

Hello, I have this script

ls -ltr | awk '{print$9}' | sed 's/_R.*$//g' | uniq | head -9 | sed -n '1!p' > list

while read -r line

do
       echo $line\_R2-paired.fastq.gz
       echo "%%%%%%%%%%%%%%%%"
               echo " hisat2 -p 8 --dta -q --phred33 -x /scratch/saragood/dimitri/L002_zipped/imam002_hisat_repo/imam002 \
                        -1 /scratch/saragood/dimitri/L002_zipped/paired/$line\_R2-paired.fastq.gz \
                        -2 /scratch/saragood/dimitri/L002_zipped/paired/$line\_R1-paired.fastq.gz \
                        -S /scratch/saragood/dimitri/L002_zipped/sams/$line.sam"
done < list

rm list


And I want it to look like this when I run it:

-1 /scratch/saragood/dimitri/L002_zipped/paired/RNA-CCC_8T1_S6_L002_R2-paired.fastq.gz

and because of the backslash after $line it turns out like this:

-1 /scratch/saragood/dimitri/L002_zipped/paired/RNA-CCC_8T1_S6_L002\_R2-paired.fastq.gz

Please tell me how to remove this unnecessary backslash for me? If you just remove it, then it turns out

-1 /scratch/saragood/dimitri/L002_zipped/paired/-paired.fastq.gz

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2020-04-27
@wolverine777

Try replacing all $line\ with ${line}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question