01.sh (404B)
1 #!/bin/sh 2 3 common=0 4 5 while read -r line; do 6 range0="${line%,*}" 7 min0="${range0%-*}" 8 max0="${range0#*-}" 9 10 range1="${line#*,}" 11 min1="${range1%-*}" 12 max1="${range1#*-}" 13 14 if [ "$min0" -le "$min1" ] && [ "$max0" -ge "$max1" ]; then 15 common="$(( common + 1 ))" 16 continue 17 fi 18 19 if [ "$min0" -ge "$min1" ] && [ "$max0" -le "$max1" ]; then 20 common="$(( common + 1 ))" 21 continue 22 fi 23 done 24 25 echo "$common"