Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SORT:Sorting lines

Status
Not open for further replies.

Ellinas

Technical User
Feb 8, 2005
6
GB
i have a question..
i have this file:

John Jones
John Smith
Jack Smith
100100 13
Helen Bold
100200 5

how can i use sort to make it look like :

Helen Bold
John Jones
Jack Smith
John Smith
100100 13
100200 5

Surname as the major key ,firstname as the minor key and numbers at the
end.

i've read the man pages and sort -k 2,2 -k 1,1 file
will sort the surname and the first name but the numbers appear at the top..

why?
 
This works for me:
LANG=french_france.8859 sort -k 2,2 -k 1,1 file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
nope..not for me ..still the numbers at the top
 
And this ?
LC_ALL=fr_FR sort -k 2,2 -k 1,1 file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
$ LC_ALL=fr_FR sort -k 2,2 -k 1,1 file.awk
100100 13
100200 5
Helen Bold
John Jones
Jack Smith
John Smith


nope .
is there another way of doing it? i mean like using awk or somthing
 
And this ?
(grep -v '^[0-9]' file | sort -k 2,2 -k 1,1; grep '^[0-9]' file | sort -k 2,2 -k 1,1) > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
i cant believe it ...it workd..thank SOO much..i got stuck for a while....thanz again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top