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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sort by one columnt and then by another

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
PL
Hello,
please tell me why second sort ignores -k4,4 sort?

# sort -t"," -k4,4 test
4,c,d,a,a
6,a,d,b,d
7,a,d,b,d
8,a,d,b,d
9,a,d,b,d
1,d,c,c,a
5,a,b,c,d
2,b,c,d,a
3,a,b,d,d
# sort -t"," -k4,4 -nk1,1 test
1,d,c,c,a
2,b,c,d,a
3,a,b,d,d
4,c,d,a,a
5,a,b,c,d
6,a,d,b,d
7,a,d,b,d
8,a,d,b,d
9,a,d,b,d


kind regards,
 
Hi

As far as I know, the [tt]-n[/tt] option applies the entire sorting.

With GNU coreutils [tt]sort[/tt] you can append an ordering option to each [tt]-k[/tt] criteria separately. See if your [tt]sort[/tt] supports it too :
Code:
sort -t"," -k4,4 -k1,1[highlight]n[/highlight] test


Feherke.
feherke.ga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top