Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.questions Subject: Re: Shell Programming Question - sort Keywords: sort, reverse, awk Message-ID: <7338@jpl-devvax.JPL.NASA.GOV> Date: 8 Mar 90 02:42:18 GMT References: <751@ncs.dnd.ca> <3190@hcx1.SSD.CSD.HARRIS.COM> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 22 In article <3190@hcx1.SSD.CSD.HARRIS.COM> brad@SSD.CSD.HARRIS.COM (Brad Appleton) writes: : I believe that BSD Unix should have a command called "reverse" which : reverses the characters in each line of a file. Run your file through : reverse, then sort, then back through reverse (this may not work : depending upon how fancy a sort you need to do). : : reverse file | sort [options] | reverse [-] > outfile Kinda hard to sort on a numeric field that way tho, which I think he wanted... : Just in case you dont have reverse... It is easy to write! It's even easier than a 97 line C program: perl -ne 'chop; print reverse "\n", split(//);' But probably not as efficient. Especially if you include the time to install perl. :-) Larry Wall lwall@jpl-devvax.jpl.nasa.gov