sort command does not work as expected in RHEL 6 when obsolete key format is used

Solution Unverified - Updated -


  • Red Hat Enterprise Linux (RHEL) 6
  • package coreutils, version < 8.4-19.el6_4.2


sort on Red Hat Enterprise Linux (RHEL) 6 does not behave as expected when obsolete key format is used, as incorrect output is produced.


Update package coreutils to 8.4-19.el6_4.2 (released with RHBA-2013-0858) or to a later version, which solves this issue. This fix is already included in RHEL 6.5 and later.

Root Cause

When parsing the file content and the end of a field was specified using the obsolete key formats (+POS -POS), the sort utility determined the end of the field incorrectly, and therefore produced incorrect output. This was a regression between RHEL 5 and RHEL 6.

Diagnostic Steps

Sorting a file with the following lines produces incorrect output on RHEL 6:

a b e
a b c

The following command returns 2 lines on RHEL 6, while on RHEL 5, the same command returns a single line abc which is the expected result:

$ sort -u -2 0 file

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.