Bash: replace part of filename

雨燕双飞 提交于 2019-12-02 01:31:58

You can use:

tophat -o "${f/.fastq/.bam}" "$f"

Testing:

f='path/to/sample1.fastq'
echo "${f/.fastq/.bam}"
path/to/sample1.bam

Not an answer but a suggestion: as a bioinformatician, you shoud use GNU make and its option -j (number of parallel jobs). The Makefile would be:

.PHONY:all
FASTQS=$(shell ls *.fastq)

%.bam: %.fastq
    tophat -o $@ $<

all:  $(FASTQS:.bam=.fastq)

Alternative to anubhava's concise solution,

d=$(dirname path/to/sample1.fastq)
b=$(basename path/to/sample1.fastq .fastq)
echo $d/$b.fastq
path/to/sample1.fastq

tophat -o "$d/$b.fastq" "$f"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!