Pages

Wednesday, May 29, 2013

Unix Sort by Column Number

I always forget the flags to use when using UNIX sort.  Here is a list of common useful flags.

Flags
-k: selects the column number to sort
-n: indicates you are sorting numeric values so use numeric ordering (ex: 10, 11, not 10, 100)
-r: sort in reverse (descending) order for this column

An example line of code that sorts by numeric values in column 2 in descending order would be as follows.

1 comment: