在
bash
下面我正在循环通过
.fastq
文件并在注释命令中使用它们。变量
$pre
它的名字在里面,它确实提取了它,我不知道的问题是如何只在注释命令中使用它一次?在下面的示例中
$PRE
是
NA11111
但提取了两次。有没有一种方法只在命令中使用一次?我尝试删除重复项
awk
没有运气和尝试
cut
. 谢谢:)。
猛击
for file in /home/cmccabe/Desktop/fastq/*.fastq ; do
sample=${file%.fastq}
bname=`basename $sample`
pre="$(echo $bname|cut -d- -f1,1)"
#bwa mem -M -t 16 /home/cmccabe/Desktop/NGS/picard-tools-1.140/resources/ucsc.hg19.fasta "$sample.fastq" "$sample" /home/cmccabe/Desktop/fastq/${pre}_aln.sam
echo "$sample.fastq"
echo "$sample"
echo "$pre"
done
电流输出
/home/cmccabe/Desktop/fastq/NA11111-100ng-E08A-C06_S5_L001_R1_001.fastq `this is $sample.fastq`
/home/cmccabe/Desktop/fastq/NA11111-100ng-E08A-C06_S5_L001_R1_001 `this is $sample`
NA11111 `this is $pre`
/home/cmccabe/Desktop/fastq/NA11111-100ng-E08A-C06_S5_L001_R2_001.fastq `this is $sample.fastq`
/home/cmccabe/Desktop/fastq/NA11111-100ng-E08A-C06_S5_L001_R2_001 `this is $sample`
NA11111 `this is $pre`
期望输出
#bwa mem -M -t 16 /home/cmccabe/Desktop/NGS/picard-tools-1.140/resources/ucsc.hg19.fasta "$sample.fastq" "$sample" /home/cmccabe/Desktop/fastq/${pre}_aln.sam
$sample.fastq = /home/cmccabe/Desktop/fastq/NA11111-100ng-E08A-C06_S5_L001_R1_001.fastq
$sample = /home/cmccabe/Desktop/fastq/NA11111-100ng-E08A-C06_S5_L001_R1_001
$pre = NA11111