Path: utzoo!utgpu!cs.utexas.edu!hellgate.utah.edu!dog.ee.lbl.gov!ucbvax!UUNET.UU.NET!kyle From: kyle@UUNET.UU.NET (Kyle Jones) Newsgroups: alt.sources.d Subject: shell pipeline to reverse the order of lines. Message-ID: <9102151917.AA04419@wendy-fate.UU.NET> Date: 15 Feb 91 19:17:16 GMT References: <1991Feb15.164342.4552@midway.uchicago.edu> Sender: daemon@ucbvax.BERKELEY.EDU Lines: 8 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]*.//'