sorting based on a specified column in a text file

I have a tab delimited file with 5 columns

79      A   B   20.2340 6.1488  8.5086  1.3838
87      A   B   0.1310  0.0382  0.0054  0.1413
88      A   B   46.1651 99.0000 21.8107 0.2203
89      A   B   0.1400  0.1132  0.0151  0.1334
114    A   B   0.1088  0.0522  0.0057  0.1083
115    A   B   0.1133  0.0763  0.0080  0.1051

I want to sort from lowest to highest based on column 5. I tried using the unix command sort but don't know how to specify column 5.

Please let me know a way to sort it based on specifying a column either using unix or awk or shell scripting

Try:

sort -nk5 file
1 Like

If need more columns, ex. grouping using col1 and sort using col5, both are numeric.

sort  -k 1,1n -k 5,5n