0

I am doing a usual thing that I sort -n but this time it does not work for the following input list, partially like

./firedock-output_308.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 54.06
./firedock-output_286.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 17.91
./firedock-output_26.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 18.86
./firedock-output_7.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 24.29
./firedock-output_843.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 17.88
./firedock-output_115.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 142.42

and the output after sort -k1,1n is

./firedock-output_1000.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 95.86
./firedock-output_100.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 12.62
./firedock-output_101.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 33.89
./firedock-output_102.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 19.83
./firedock-output_103.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 19.69
./firedock-output_104.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 69.43
./firedock-output_105.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 25.11
./firedock-output_106.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 17.46
./firedock-output_107.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 41.77
./firedock-output_108.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 12.61
./firedock-output_109.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 72.75
./firedock-output_10.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 67.79
./firedock-output_110.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 13.87
./firedock-output_111.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 18.44
./firedock-output_112.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 27.03
./firedock-output_113.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 37.43
./firedock-output_114.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 18.57
./firedock-output_115.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 142.42
./firedock-output_116.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 57.75
./firedock-output_117.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 21.21

Why sort -n does not work as it normally does (i.e. sort according to numerical order) for this case?

What I want is

./firedock-output_1.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 12.62
./firedock-output_2.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 12.62
./firedock-output_3.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 12.62
./firedock-output_4.ref_clashscore_cat_elmo1-NT_rhog1_clashscore:clashscore = 12.62

until 1000 (totally there are 1000 lines).

Thanks.

  • 2
    Try sort -V. From man "natural sort of (version) numbers within text" – Deeh Mar 22 at 3:25
0

OK, solved. I need to specify the position of sort key, which is the 19th character.

sort -n -k1.19

Thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.