Ancient sort version?

Colin Watson cjwatson at ubuntu.com
Mon Aug 5 20:32:16 UTC 2013


On Mon, Aug 05, 2013 at 03:10:03PM -0500, Linda wrote:
> On 08/05/2013 01:56 PM, Mike Kupfer wrote:
> >So "sort +2" is equivalent to "sort -k 3". cheers, mike
> 
> Just curious what -k denotes I checked man sort and it says start a
> key at POS1 end at POS2 but I'm not sure what that means. So what is
> a key?
> I've always used -t and sorted by fields just curious what it means
> to sort by a key.

-t changes how fields are delimited; -k selects which fields (or
characters within those fields) to sort on.  As an example:

  $ cat input
  key1:ccc
  key2:bbb
  key3:aaa
  $ sort -t: -k2 input
  key3:aaa
  key2:bbb
  key1:ccc

-- 
Colin Watson                                       [cjwatson at ubuntu.com]




More information about the ubuntu-users mailing list