Linux Tip: SORT of linux
If you want to sort a tab limited file in ascending order according to one column (like 5th column), you can use:
sort -k5,5n input
However, if you want to sort the file in descending order ccording to one column (like 5th column), you cann't use:
sort -r -k5,5n input 
You can use:
sort -r n-k5,5 input 
 -n, --numeric-sort
          compare according to string numerical value
-r, --reverse
         reverse the result of comparisons
Comments
Post a Comment