Shell Programming Question - sort
Larry Wall
lwall at jpl-devvax.JPL.NASA.GOV
Thu Mar 8 12:42:18 AEST 1990
In article <3190 at hcx1.SSD.CSD.HARRIS.COM> brad at 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 at jpl-devvax.jpl.nasa.gov
More information about the Comp.unix.questions
mailing list