[olug] sort -u vs uniq
hwolfe71 at gmail.com
Mon Mar 13 11:08:06 CDT 2017
I have a e-book on shell scripting that covers almost this exact situation.
It is sorting the hosts file, so doesn't use unique, but the rest is the
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n -u
Where -t. Is used to specify the . as the delimiter, while -k1,1n indicates
that the first key is field 1 to 1, inclusive, and is numeric, rather than
On Mar 13, 2017 10:23 AM, "Noel Leistad" <noel at metc.net> wrote:
I'm trying to get a list of uniq IP addresses from a log file. I have a
list of ALL IP addresses. Using sort -nu and sort -n | uniq give me 2
A stare and compare make me think that sort -nu only considers the first 2
octets as significant. RTFM of the sort man page indicates sort honors
LC_COLLATE isn't in env, so I'm assuming it's set at build/compile time
when building sort or in the c libraries someplace?
</appear uninformed -- hardly, stupid probably better tag... and not
Could this be why the sort -u and uniq return differing output? I don't see
anyplace to specify "how much" to consider significant when running sort.
Anyone care to offer thoughts?
OLUG mailing list
OLUG at olug.org
More information about the OLUG