Find for all features in `file1.bed` the closest one in `file2.bed` and write their [d]istance in an extra column (input files must be sorted)
bedtools closest -a path/to/file1.bed -b path/to/file2.bed -d