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 acer asus bios bsod computer crash driver drivers error ethernet excel freeze games gaming graphics hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network operating system printer problem ram random registry router security slow software sound trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
sorting

Reply  
Thread Tools
oldshep's Avatar
Junior Member with 22 posts.
 
Join Date: Jul 2004
28-Jul-2004, 06: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
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
28-Jul-2004, 09: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, 01: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, 01: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
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
30-Jul-2004, 03:23 PM #5
sort -b +1 -2 +4r -5
oldshep's Avatar
Junior Member with 22 posts.
 
Join Date: Jul 2004
02-Aug-2004, 04: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
Reply

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.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:45 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.