script
#!/bin/bash
filea=$1
fileb=$2
fout=$3
sed -i "/^$/d" $filea $fileb
cat $filea | while read a b c
do
grep "$a.*$b.*$c" $fileb &>/dev/null && l="$a $b $c 1" || l="$a $b $c 0"
grep "$l" $fout &>/dev/null || echo "$l" >> $fout
done
cat $fileb | while read a b c
do
grep "$a.*$b.*$c" $filea $fout &>/dev/null && l="$a $b $c 1" || l="$a $b $c 0"
grep "$l" $fout &>/dev/null || echo "$l" >> $fout
done
stdout
younes@cbfcdf:~$ cat filea
chr1 899 1098
chr3 677 900
chr3 844 1045
younes@cbfcdf:~$ cat fileb
chr3 844 1045
chr1 899 1098
chr4 500 789
younes@cbfcdf:~$ ./script filea fileb new_file
younes@cbfcdf:~$ cat new_file
chr1 899 1098 1
chr3 677 900 0
chr3 844 1045 1
chr4 500 789 0
younes@cbfcdf:~$