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!

sorting in Unix 1

Status
Not open for further replies.

kasparov

Programmer
Feb 13, 2002
203
GB
I always struggle with the Unix sort command. I have a file with many (100+) comma separated fields. I want to sort it first by field 43, then by field 15. I've tried each of these & none of them works (sometimes it seems as though they do but when I look at the data more closely I see errors).

sort -t , +43 +15

sort -t , -k 43,15
sort -t , -k 43 -k 15

Field 43 will have values like this:
HOME
PP190050
PP190230
PP410001
PP31C006NS
PP31C007

Field 15 is always 8 numerics beginning with 3 zeros, e.g.:
00021946
00030935
00021254

Can anyone help?
 
And what about this ?
sort -t, -k 43,43 -k 15,15

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV - I need to check the output more closely but it looks good so far.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top