来自bash脚本的输出文件夹

时间:2014-01-06 14:33:44

标签: bash

我有bash脚本:

 for x in *.bam; 
do  bamToBed -i $x > ${x%.bam}.bed; 
done

但我不知道如何设置.bed文件的输出文件夹(从脚本输出)。

1 个答案:

答案 0 :(得分:2)

## Define the folder you want to use for .bed files
outputFolder=/your/output/folder
## Make sure the folder is created
mkdir -p "$outputFolder"

for x in *.bam; do
    ## Redirect the output to a file in the above defined folder
    bamToBed -i "$x" > "$outputFolder/${x%.bam}.bed"
done