I want to use SORT command to sort a tabular file based on the 5th column, however, there are some missing values in the 3rd column. And I noticed that sort command does not work properly with -k5,5, but -k1,1 or -k2,2 has no problem. Is it because of the missing values?
Share
By default,
sortbelieves that a field begins whenever there’s a whitespace character followed by a non-whitespace character. For example, in this snippet:the first line has four fields, and the second line has three fields.
If you want to use a different separator, you can specify that by using the
-toption. For example, to use tabs as separators, you can write:That will let
sortdetect empty fields (because two consecutive tabs will be interpreted as two different separators, with an empty field between them).