From: Pádraig Brady Date: Fri, 30 Sep 2022 14:44:30 +0000 (+0100) Subject: doc: sort: mention --version useful for IPv4 addresses X-Git-Tag: v9.2~123 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fd708810ce0e0d967c4c14e1ff2ff7b43440b58;p=thirdparty%2Fcoreutils.git doc: sort: mention --version useful for IPv4 addresses * doc/coreutils.texi (sort invocation): Mention in the multi invocation sort example that the -V GNU extension could be used to sort IPv4 addresses, and thus simplify to a single invocation. --- diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 471c50e8c3..3328cd8999 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -4971,7 +4971,7 @@ sort -s -t ' ' -k 4.9n -k 4.5M -k 4.2n -k 4.14,4.21 file*.log | sort -s -t '.' -k 1,1n -k 2,2n -k 3,3n -k 4,4n @end example -This example cannot be done with a single @command{sort} invocation, +This example cannot be done with a single POSIX @command{sort} invocation, since IPv4 address components are separated by @samp{.} while dates come just after a space. So it is broken down into two invocations of @command{sort}: the first sorts by timestamp and the second by IPv4 @@ -4983,7 +4983,9 @@ based on leading prefixes that cannot cross field boundaries. The IPv4 addresses are sorted lexicographically. The second sort uses @samp{-s} so that ties in the primary key are broken by the secondary key; the first sort uses @samp{-s} so that the combination of the two -sorts is stable. +sorts is stable. Note as a GNU extension, the above example could +be achieved in a single @command{sort} invocation by sorting the +IPv4 address field using a @samp{V} version type, like @samp{-k1,1V}. @item Generate a tags file in case-insensitive sorted order.