Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!jarthur!uunet!tellab5!vpnet!dattier From: dattier@vpnet.chi.il.us (David W. Tamkin) Newsgroups: comp.unix.shell Subject: Re: How to sort on right most column Message-ID: <1991May23.233443.17752@vpnet.chi.il.us> Date: 23 May 91 23:34:43 GMT References: <1991May15.140902.23225@convex.com> <1991May22.191522.19709@jpradley.jpr.com> Organization: VPnet Public Access Unix, Villa Park, Illinois 60181-2206 Lines: 29 jpr@jpradley.jpr.com (Jean-Pierre Radley) wrote in <1991May22.191522.19709@jpradley.jpr.com>: | >From the keyboard of felps@convex.com (Robert Felps): | >:I don't know of any way to sort based on right to left. But you might try | With awk, $NF is the last field. So pipe the file through awk, prepending | the last field ($NF) to the whole line ($0), separated by something wierd, | say ^B. Pipe this to sort, then pipe to a sed to ditch characters up to and | including the ^B. | As I think of it, the first awk could be a sed filter too. You know, if you're looking to replace the original file with a sorted one, you could do the whole thing in ex. Let's say your field separator is a space: ex - file << \,, %s/.* \(.*\)/\1 &/ %!sort %s/[^ ]* // wq ,, David Tamkin PO Box 7002 Des Plaines IL 60018-7002 dattier@vpnet.chi.il.us GEnie:D.W.TAMKIN CIS:73720,1570 MCIMail:426-1818 708 518 6769 312 693 0591 "Parker Lewis Can't Lose" mailing list: flamingo-request@esd.sgi.com (relay) flamingo-request@ddsw1.mcs.com (digest)