How to sort on right most column
Robert Felps
felps at convex.com
Wed May 15 23:11:08 AEST 1991
In <13320 at exodus.Eng.Sun.COM> rock at warp.Eng.Sun.COM (Bill Petro) writes:
>How could I do this using either the sort command, or perl or awk?
>I have the following data in this format - I want to sort it on the
>right most column. The columns are not tab delimited, and some of the
>columns have arbitrary numbers of words (specifically the third column
>from the left, column c). Sort assumes that you start numbering on the
>left, and count from 0. How would you start with the right most
>column, column e?
> 0 1 2 3 4
> a b c c e
> FOO BAR ACE CORPORATION SUNNYVALE 2.00
> FOO BAR ACER COMPUTED COMPANY MILPITAS 20.00
> FOO BAR APOLLO COMPUTER, INC. CHELMSFORD 1.00
> FOO BAR APPLE COMPUTER, INC. CUPERTINO 8.00
> FOO BAR BOEING TUKWILA 53.00
> FOO BAR BOEING COMPUTER SERVICES EDDYSTONE 2.00
> FOO BAR CITIBANK N. A. ANDOVER 4.00
> FOO BAR CITIBANK NORTH AMERICA LONG ISLAND CITY 26.00
I don't know of any way to sort based on right to left. But you might try
$ sort +0.60bn -0.70bn data
Which sorts columns 60 thru 70 ignoring blanks and using numeric values to
sort on.
>Thanks!
>--
> Bill Petro {decwrl,hplabs,ucbvax}!sun!Eng!rock
>"UNIX for the sake of the kingdom of heaven" Matthew 19:12
Hope it helps,
Robert Felps I do not speak for felps at convex.com
Convex Computer Corp Convex and I seldom Product Specialist
3000 Waterview Parkway speak for myself. Tech. Assistant Ctr
Richardson, Tx. 75080 VMS? What's that? 1(800) 952-0379
More information about the Comp.unix.shell
mailing list