From 4fd708810ce0e0d967c4c14e1ff2ff7b43440b58 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Fri, 30 Sep 2022 15:44:30 +0100 Subject: [PATCH] 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. --- doc/coreutils.texi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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. -- 2.47.2