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) |