reversing lines

Stephen P. Kemp kemp at noscvax.UUCP
Wed Sep 19 02:47:49 AEST 1984


On 4.2 bsd systems, the following will work (I think there are no restrictions
regarding the file contents):

     % cat -n filename | sort -nr | sed "s/^.......//" 

cat -n prefixes the input with lines numbers; sort -nr sorts using the numbers
as the sort key, and outputs the lines in reverse order; sed strips the 
line numbers off again and the result ought to be what you want.

Steve Kemp	 {ihnp4, decvax, akgua, dcdwest, ucbvax}!sdcsvax!noscvax!kemp
Computer Sciences Corp.         kemp at nosc
Naval Ocean Systems Center
San Diego, CA
  



More information about the Comp.unix mailing list