dormi330
dormi330

Reputation: 1353

linux sort not work correctly

I found cat not working correctly.

>cat bbb.txt
1343,10360
1193,10424
337,10222
306,10518
209,10410
1954,4861
190,10101
1811,6134
173,10555
1725,6542
97,9596
50,9996
20,5049
15,6007
10,6400

I want to sort it with column1, numberic, so

>_ sort -t","  -k1 -nr  bb.txt 
1343,10360
1193,10424
337,10222
306,10518
209,10410
1954,4861
190,10101
1811,6134
173,10555
1725,6542
97,9596
50,9996
20,5049
15,6007
10,6400

If I replace all ',' with ';' it works. Is there a way to solve it?

Upvotes: 0

Views: 69

Answers (1)

Kent
Kent

Reputation: 195229

kent$  sort   -nrt',' -k1,1  file     
1954,4861
1811,6134
1725,6542
1343,10360
1193,10424
337,10222
306,10518
209,10410
190,10101
173,10555
97,9596
50,9996
20,5049
15,6007
10,6400

If you do sort -k1, it sort from field1 till the end of the line.

read the KEYDEF part of man sort

Upvotes: 2

Related Questions