$ echo "2 21" | perl -nle 's/(\d*)(\d*)\s+\1(\d*)/$1$2-$3/; s/-$// +; print' 2-1 [download]
Abigail
In reply to Re: eliding number ranges by Abigail-II in thread eliding number ranges by qq