Hi jean.elbers
I tried this so far,
bioinfo$ for i in *.bed ; do echo $i ; echo ; cat $i ; echo ; done
test1.bed
chr1 20 30
test2.bed
chr1 15 25
test.bed
chr1 10 30
--
bioinfo$ bedtools multiinter -i test1.bed test2.bed test.bed
chr1 10 15 1 3 0 0 1
chr1 15 20 2 2,3 0 1 1
chr1 20 25 3 1,2,3 1 1 1
chr1 25 30 2 1,3 1 0 1
--
bioinfo$ bedtools multiinter -i test1.bed test2.bed test.bed > out
--
bioinfo$ cat out
chr1 10 15 1 3 0 0 1
chr1 15 20 2 2,3 0 1 1
chr1 20 25 3 1,2,3 1 1 1
chr1 25 30 2 1,3 1 0 1
bioinfo$ files="$(ls *.bed|wc -l)"
--
bioinfo$ echo $files
3
--
But below command generates nothing
bioinfo$ awk -v OFS='\t' -v files=files '$4==files' out
This works but I cannot keep on writing names of all bed files one by one when I have 100's of files!
I know right :) But you should have had in your post that you got more than 3 bed files
It was a toy example from bedtools page as I had mentioned. Thanks Bastien Hervé for a quick response. I highly appreciate that :D
I offered a solution that generalizes to many files but ended up deleting it. Sorry and good luck!