I want to find common pieces (regions) between the below coordinates in two big files?
file1: file2: chr1:251790423-251855075 chr1:251391746-251411804 chr1:259520908-259580523 chr1:259687605-259759271 chr1:261294390-261396569 chr1:259815659-259854201 chr2:108327854-108382699 chr2:108327854-108388888 chr20:28151226-28420685 chr20:28141234-28520687 chr3:15673814-15987811 chr3:15673814-15997815 chr10:70552773-71399757 chr10:70782782-71499757
I have tried:
cat file1 file2 | sed "s/[-:]/\t/g" | bedtools sort | bedtools merge > result
But it can only merge them. I would be thankful if I could have your kind suggestions regarding to find only common regions (without extra lengths) between two files.