Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!convex!felps From: felps@convex.com (Robert Felps) Newsgroups: comp.unix.shell Subject: Re: How to sort on right most column Message-ID: Date: 15 May 91 13:11:08 GMT References: <13320@exodus.Eng.Sun.COM> Sender: usenet@convex.com (news access account) Organization: CONVEX Computer Corporation, Richardson, Tx., USA Lines: 45 Nntp-Posting-Host: mikey.convex.com In <13320@exodus.Eng.Sun.COM> rock@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@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