Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have ten .bam files (bioinformatic format) and I would like to convert it to 10 .bed files, but for this conversion I need to use special command

bedtools bamTobed -i (input file) > output file.bed
share|improve this question
up vote 1 down vote accepted

Your question is not very clear, but maybe this shell command helps.

for x in *.bam; do
    bedtools bamTobed -i "$x" >"${x%.bam}.bed"
share|improve this answer
It works, thank you so much – user48932 Oct 10 '13 at 13:19

you can do something like:

parallel --jobs <int> "bamToBed -i {} > {.}.bed" ::: *.bam
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.