简体   繁体   中英

for loop to echo the sequential command lines?

how to use for loop in linux to generate the following lines?

zcat ~/tools/sample66621D.fastq | bowtie2 -a - | samtools ->sample66621D.BAM
zcat ~/tools/sample66622D.fastq | bowtie2 -a - | samtools ->sample66622D.BAM
zcat ~/tools/sample66623D.fastq | bowtie2 -a - | samtools ->sample66623D.BAM

I've tried:

for ((a=21;a<=23;a++))
  echo "zcat ~/tools/sample666$aD.fastq | bowtie2 -a - | samtools ->sample666$aD.BAM"
done

but it turned to be three identical lines .

zcat ~/tools/sample666.fastq | bowtie2 -a - | samtools ->sample666.BAM
zcat ~/tools/sample666.fastq | bowtie2 -a - | samtools ->sample666.BAM
zcat ~/tools/sample666.fastq | bowtie2 -a - | samtools ->sample666.BAM

thanks

$aD is a valid variable name. You must delimit the variable name with brackets, ie ${a} .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM