Bug 12216 - sort: unique deletes to much/wrong lines
Summary: sort: unique deletes to much/wrong lines
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.31.x
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-16 20:27 UTC by 4yg_4mm6p8ifiten
Modified: 2020-01-25 12:30 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 4yg_4mm6p8ifiten 2019-09-16 20:27:21 UTC
a line is missing:

echo -e "1a\n1b\n2a" | sort -un
1a
2a


as expected:

echo -e "1a\n1b\n2a" | sort -u | sort -n
1a
1b
2a
Comment 1 Ron Yorston 2020-01-25 12:30:09 UTC
I don't think this is a bug.

Firstly, coreutils 'sort' exhibits the same behaviour.

Secondly, the man page for POSIX 'sort' says that the '-u' option will "suppress all but one in each set of lines having equal keys" and that the '-n' option will "restrict the sort key to an initial numeric string". When these options are combined only the numeric part of the line is used to determine lines are unique.