Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Linux and Unix
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop drivers dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem processor ram recovery router safe mode screen slow sound spyware tdlwsp.dll trojan video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
sorting

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
oldshep's Avatar
Junior Member with 22 posts.
 
Join Date: Jul 2004
28-Jul-2004, 05:23 PM #1
sorting
I'm pretty sure that in Sco Unix if you were sorting on several keys it was possible to have some in normal a-z sequence and some in reverse z-a sequence. It all depended on where you placed the -r option in relation to the key + - specifications.

How in RedHat if sorting on several keys can you have some in ascending order and others in reverse?
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
28-Jul-2004, 08:18 PM #2
Could you give me a small example of what you want the output to look like. I don't quite understand. How does it work in SCO Unix.
oldshep's Avatar
Junior Member with 22 posts.
 
Join Date: Jul 2004
29-Jul-2004, 12:25 AM #3
Quote:
Originally Posted by LwdSquashman
Could you give me a small example of what you want the output to look like. I don't quite understand. How does it work in SCO Unix.
oldshep's Avatar
Junior Member with 22 posts.
 
Join Date: Jul 2004
29-Jul-2004, 12:42 AM #4
A file named addresses :

Mary Adamas f 34 Pickhurst Lane. Chisolm L.Hutt 6345678
Peter Anderson m 78 Aylesbury Rd. Rotherham Sheffield 7845323
Peter Anderson M 78 Aylesbury Rd. Rotherham Sheffield 7845323
Lynda Ball F 129 Wordsworth Ave. Sheffield L.Hutt 6645323
Fred Barton M 213 High St. Godalming U.Hutt 7947478
Fred Benjamen M 231 High St. Godalming U.Hutt 2346782
Maggie Benson f 14 Moorfield Ave. Chesterfield Derbys 5745678
Andy Benson m 127 Upton Grove Halesham Wellington 8465390
Mary Billings f 64 Pickhurst Lane. Chisolm L.Hutt 6574364
Jill Bloggs f 156 Grenville Close Basingstoke L.Hutt 6354666
James Bloggs m 165 Ampton Close Basingstoke L.Hutt 6456789
John Bloggs m 156 Classy Cres Basingstoke L.Hutt 6354666
Janet Bloggs f 165 Fanshaw St. Basingstoke L.Hutt 6456789
Paul Bracknell m 209 Stanton Rd. Lincoln Wellington 8653421

sort -b +1 -2 addresses (would sort on surname , no problem)
sort -b -r +1 -2 addesses (would sort on reverse surname , no problem)

In Sco ( as I recall) if I wanted to sort say normal on surname but in reverse only on a secondary key i.e. on the first part of address key 4, then
sort -b +1 -2 +4 -5 -r addresses ( would sort ascending on +1 but descending on +4 because the -r was placed after the key)

On Redhat it seems that the -r will sort in reverse on all keys.
For the above file all the Bloggs would be together how do I sort so that the order of address would be:

Jill Bloggs f 156 Grenville Close Basingstoke L.Hutt 6354666
Janet Bloggs f 165 Fanshaw St. Basingstoke L.Hutt 6456789
John Bloggs m 156 Classy Cres Basingstoke L.Hutt 6354666
James Bloggs m 165 Ampton Close Basingstoke L.Hutt 6456789

(that is, all Bloggs in ascending but the address in reverse from Grenville to Ampton)
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
30-Jul-2004, 02:23 PM #5
sort -b +1 -2 +4r -5
oldshep's Avatar
Junior Member with 22 posts.
 
Join Date: Jul 2004
02-Aug-2004, 03:13 AM #6
Thanks worked a treat.. My problem was purtting the r with a minus i.e. +4 -5 -r rather than using the r on its own with no minus i.e. +4r -5 OR +4 -5 r
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 01:23 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.