After seeing a couple of programs in Perl and Icon to do this, I feel compelled to post a shell pipeline solution to this problem. cat -n | sort -rn | sed 's/ *[0-9]*.//' For System V folks whose cat(1) doesn't have -n, just use awk: awk '{ printf "%10d\t%s\n", NR, $0 }' | sort -rn | sed 's/ *[0-9]*.//'