From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 12 04:45:15 2016 Received: (at submit) by debbugs.gnu.org; 12 Nov 2016 09:45:15 +0000 Received: from localhost ([127.0.0.1]:54425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c5Us7-0003Yw-0M for submit@debbugs.gnu.org; Sat, 12 Nov 2016 04:45:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:34074) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c5Us5-0003Yi-N0 for submit@debbugs.gnu.org; Sat, 12 Nov 2016 04:45:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5Urz-0001vw-GB for submit@debbugs.gnu.org; Sat, 12 Nov 2016 04:45:08 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: ** X-Spam-Status: No, score=2.9 required=5.0 tests=BAYES_50,DATE_IN_PAST_06_12, RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42278) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c5Urz-0001vq-Cy for submit@debbugs.gnu.org; Sat, 12 Nov 2016 04:45:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5Ury-0000j2-D7 for bug-coreutils@gnu.org; Sat, 12 Nov 2016 04:45:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5Urt-0001sZ-HY for bug-coreutils@gnu.org; Sat, 12 Nov 2016 04:45:06 -0500 Received: from homie.mail.dreamhost.com ([208.97.132.208]:51503 helo=homiemail-a8.g.dreamhost.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c5Urt-0001s7-96 for bug-coreutils@gnu.org; Sat, 12 Nov 2016 04:45:01 -0500 Received: from homiemail-a8.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a8.g.dreamhost.com (Postfix) with ESMTP id 017245F2068 for ; Sat, 12 Nov 2016 01:44:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to :subject:date:message-id:mime-version:content-type; s= jidanni.org; bh=4rd/Xyq68CUCDxt6rxGT1RFxRNs=; b=cRuSPWOD5J9suLq8 OAfppJ/9RgrXQ2NfpbfFTUsgyUF3Ds91FPU0WPBK9DEaObs41667SEgX7JwMsPPb 9oBioCtgNkATRpZMMlip148SHAVTVpOSf6YXmKn6zJGaLQaAg9ct+DBFHO867hmF u1mWv4WC1ku41mua2ZEGpxYcEJE= Received: from jidanni.org (111-246-98-191.dynamic.hinet.net [111.246.98.191]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a8.g.dreamhost.com (Postfix) with ESMTPSA id A64E75F2067 for ; Sat, 12 Nov 2016 01:44:58 -0800 (PST) From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson To: bug-coreutils@gnu.org Subject: comm enhancement proposal: --print-summary --quiet Date: Sat, 12 Nov 2016 07:24:35 +0800 Message-ID: <87twbdfvm4.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) Please add a comm --print-summary and --quiet, so we wouldn't have to write $ comm FILE1 FILE2|perl -nwe ' /^\t+/; $h{ length $& || 0 }++; END { @L = ( "Lines in 1st ", "Lines in 2nd ", "Lines in both" ); printf "%s: %5d\n", $L[$_], $h{$_} for sort keys %h; } ' Lines in 1st : 601 Lines in 2nd : 437 Lines in both: 2417 (Which would get fooled by leading tabs in the files anyway.) (Or add "only": 'Lines only in 1st'...) --print-summary Print totals at end. --quiet Suppress file content output. In fact my formatting is ugly. Make it look like the output of $ wc -l FILE1 FILE2 Thanks. From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 14 05:30:24 2016 Received: (at 24929) by debbugs.gnu.org; 14 Nov 2016 10:30:24 +0000 Received: from localhost ([127.0.0.1]:56389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6EWt-0003Q6-RL for submit@debbugs.gnu.org; Mon, 14 Nov 2016 05:30:23 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:64201) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6EWs-0003Pt-AV for 24929@debbugs.gnu.org; Mon, 14 Nov 2016 05:30:22 -0500 Received: from [10.0.2.15] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MUW15-1cFPTb0xIR-00REuD; Mon, 14 Nov 2016 11:30:13 +0100 Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet To: =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 24929@debbugs.gnu.org References: <87twbdfvm4.fsf@jidanni.org> From: Bernhard Voelker Message-ID: <561455b4-f33d-8ac3-223b-556bc54acc2d@bernhard-voelker.de> Date: Mon, 14 Nov 2016 11:30:03 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <87twbdfvm4.fsf@jidanni.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:YMem2rCzHRUn8Ak2an2HVKomF/LUa84HUhVYxXnETTnq3gExF9X 1j9yiDIOrNrFlFPjhv21uS4J2L9zzpFWMER1TF+S4/vKOb1R+f1q56VcZ0p/nw4Gv14sSF8 zBR8xPuA+GVn4SrTj0jXyvzWyrKEFUI/ayioQhA8nmb4jV1JlMlyIu+krsdW9bnQykOSXvt Xn4jsPhpbio16tQKDcXcg== X-UI-Out-Filterresults: notjunk:1;V01:K0:lndSQp+6b3k=:0r5ShARQd54drcZ/nJrtKm AECtsQc58G+DZYKRRQUou+FSeTVjaP4Z98IRnHtv/s6pJQLoN2S0ZcXueGKHji+6YV9hvpkfY P0HQFbunML+KCVllyf30wXdLYbYRWAL3qLvusIU17haeNylikCRR0VWLNGjBdeJG+J08IOTGj XSY+oc9wagfcP1uwi0dXyZGGDdVb+3cWL9YculsxXt9uUd90UulkhsR+hFmU+RAj9A8smnwdi UNLlspDiMLsSxXeqUXgLCjxzkNbfS1sbfy7bggA0f7Pv82DDU/XzjP7hbAvCqU16SLgpH2n9G 6yNjnZX8sbYldhdM22kvEQ6tvak46CSEqYDvLML9AfTerbIHziaczoDyNItxEerPB4Jeu8ZyV vtOYOecP/FFu8h9BAU3Fv8S+OOF8HEpeFGyHHOwT2i2CUE8GgL3yBh5Ijbgz/VwIE2RPW36EV N9396VT4ENQht7Qe8caecZjHdY1NbTgC4JL7LszuvY5SYAwVqK+E1Df21pHZS5AuZ5lJKWIe1 /Z1OvdenEIl6ZQjCWtHU3dQ5m/NhSIxnLoBKvc/KmCDuR7Vhe2HP8ycbz7qS9Olf5hGrFmbrC v7hhB4qAosGkzSuaMB4u5jiuhSsCD3bv9iu6OvBhnJenSAZPQZqFm+fNctaKaRXa2VeFCCinb TZSkQM8DBuCjzzxWf1bLCe7aa5CvrUfI081MO4NP4CpsOP3g9rqN6oxMP45DpwN46JEW7BugX ZlDx83w8BGtq+hz3 X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 24929 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On 11/12/2016 12:24 AM, 積丹尼 Dan Jacobson wrote: > Please add a comm --print-summary and --quiet, so we wouldn't have to write > $ comm FILE1 FILE2|perl -nwe ' > /^\t+/; > $h{ length $& || 0 }++; > > END { > @L = ( "Lines in 1st ", "Lines in 2nd ", "Lines in both" ); > printf "%s: %5d\n", $L[$_], $h{$_} for sort keys %h; > } > ' > Lines in 1st : 601 > Lines in 2nd : 437 > Lines in both: 2417 This sounds like a domain of diffstat(1), doesn't it? Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 14 09:38:12 2016 Received: (at 24929) by debbugs.gnu.org; 14 Nov 2016 14:38:12 +0000 Received: from localhost ([127.0.0.1]:56688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6IOi-0002uf-5F for submit@debbugs.gnu.org; Mon, 14 Nov 2016 09:38:12 -0500 Received: from homie.mail.dreamhost.com ([208.97.132.208]:37317 helo=homiemail-a62.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c6IOg-0002uY-SK for 24929@debbugs.gnu.org; Mon, 14 Nov 2016 09:38:11 -0500 Received: from homiemail-a62.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a62.g.dreamhost.com (Postfix) with ESMTP id 4E21963407D; Mon, 14 Nov 2016 06:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=FBLuqeDJA9R97L1X5NoFcucrvPU=; b=SZpaFAWKNzalL GOFWfZ/eVmo/LN3t45NVQdcvGz/rz9dixSQaPB1eL7jJ+ywo0GdOmEJnUjtSdV/0 L9nMHiG8KBtsN4jGC50UmLNPc7I1BVUu+cJReamEy9H6g/m8l+rBzU6GiDWZQNHe /TrMDw5YsjaertooZT8BEC0TEaAKTE= Received: from jidanni.org (122-118-150-233.dynamic.hinet.net [122.118.150.233]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a62.g.dreamhost.com (Postfix) with ESMTPSA id 40F2E634075; Mon, 14 Nov 2016 06:38:05 -0800 (PST) From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson To: Bernhard Voelker Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet References: <87twbdfvm4.fsf@jidanni.org> Date: Mon, 14 Nov 2016 22:38:02 +0800 Message-ID: <87lgwmf7p1.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 24929 Cc: 24929@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) >>>>> "BV" == Bernhard Voelker writes: BV> This sounds like a domain of diffstat(1), doesn't it? Even if it is, and even if one could understand http://invisible-island.net/diffstat/ , it turns out the totals are already easily made within comm(1), so it would be light-years easier if comm could tell the user, instead of making him find and install a whole other program, for something that comm could, with a few more lines of code surely, just tell the user, instead of throwing away the opportunity. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 16 21:51:39 2016 Received: (at 24929) by debbugs.gnu.org; 17 Nov 2016 02:51:39 +0000 Received: from localhost ([127.0.0.1]:60025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7Cnb-0000oc-Cl for submit@debbugs.gnu.org; Wed, 16 Nov 2016 21:51:39 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:58895) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7CnZ-0000oP-89 for 24929@debbugs.gnu.org; Wed, 16 Nov 2016 21:51:38 -0500 Received: from [192.168.101.10] ([217.87.217.218]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.183]) with ESMTPSA (Nemesis) id 0M1hZS-1cwY3p0s82-00tmlE; Thu, 17 Nov 2016 03:51:27 +0100 Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet To: =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 24929@debbugs.gnu.org References: <87twbdfvm4.fsf@jidanni.org> From: Bernhard Voelker Message-ID: <74fdaf74-746e-11c3-416e-a127e19ab5cb@bernhard-voelker.de> Date: Thu, 17 Nov 2016 03:51:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <87twbdfvm4.fsf@jidanni.org> Content-Type: multipart/mixed; boundary="------------D217BF0896D64E97B4AB71C4" X-Provags-ID: V03:K0:+E+Y19m6kUdTBkiqlO7KNJZfWyzz+ZxOLfWDe2kBAFy7OXgnprL kjOY+9yJCxrlo0MxajSaTgsE+4vMQbZOZr6kkEKM7i4BwYIkyJTkdquTlcLi7T8aXLh9J7a aBuki95e+y+xHnTF6kNc8V85NIcPqaddbihL9KqIwlL5G+nBMtU8rxpY9t2NeCMX79KHnLN HnRTC7kWhXRSpceitVX8Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:0yIvuuIQzaU=:vNfGALByIxtJHMRMdOWqHB L+DnaE9b3hd6nMFVDOHgId+oTOGJVyk3k5zkPrX1xE99EmjOLKgQoruXnNPtPE7M0/Pun/oRO ZGdeYVFG/tX9odqqH3/DAGjLgNIHgPUdLi3LHjC4sYBvUeAmMSUAwZpUcf3U93be+8aWGnxZO QVwrIM2pja3GQISAgc3y/g8OLx21XXiUnMmRC8b2/fGJJ2qG6kmplnf02VheuLYEIbNqWGbrL ECMvZ+Le4C8YyLv2RtzDnv3uVSuD0CcRFHy5MDvFonR0D1cgUnElONQ9mziJSF0IJqXZZxr2l FWHH6be5yzzU8pW4TNfROUPAlQWxoZBnrNCBkpZfTcidRJOjNHV5etvN7DFLFHKPmLUBzO++V lbL9FQdRQMjBgLKOkXWUA/1su9AlH7+IsMEN6vquGZyV85OkhmCzHvOQEshuO+toisz+GcU5F Gvf+wphPv9M2K6oGl2o9uipLzLXGpWNKtnzlN+fQHVrW0M4tSfcD/N/UgsjOR4YuL9CMIyplO zs4cVkf6983GzO6WaVSc98MN/RtMrxAAJ5odLuKUkoVCU2o1rIzRz9UA/lWLTJ/gcSbrAGkem 9FVmSVR9OQvFRBQAHoh8kQh33/q0S9Wo2xyabqO1XZo3w9R9haQTPQBvGJBxt7qWevmaVHIDv 3fKs7di7XIQVfcVoaKx+BgZvR6D9feICYOFzuL9xc94ja/sXIO9qh7GX1h21jdZqKvXY= X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 24929 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) This is a multi-part message in MIME format. --------------D217BF0896D64E97B4AB71C4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/12/2016 12:24 AM, 積丹尼 Dan Jacobson wrote: > Please add [...] > --print-summary > Print totals at end. > > --quiet > Suppress file content output. Just for fun (...), I've put the requested functionality into the attached patch. I'm only 60:40 for adding this to coreutils, as this may be considered as feature creep bloating the code; OTOH the size of the additional code it not so scaring, so I'll leave the decision up to the other CU maintainers. BTW: --quiet is not needed, because you can use "-123". ;-) Have a nice day, Berny --------------D217BF0896D64E97B4AB71C4 Content-Type: text/x-patch; name="0001-comm-add-total-option.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-comm-add-total-option.patch" >From 9b3d7131329af1f74d5100598a4dcf7ed111bc32 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Thu, 17 Nov 2016 03:38:54 +0100 Subject: [PATCH] comm: add --total option * src/comm.c (total_option): Add bool variable for the new option. (TOTAL_OPTION): Add enum value. (long_options): Add array element for the new option. (usage): Document the new option here. (compare_files): Count the lines in total[3], and output the summary at the end. (main): Accept the new option. * doc/coreutils.texi (comm invocation): Document it. * tests/misc/comm.pl: Test it. While at it, improve the test data to have 1 unique line in the first file, 2 unique lines in the second file, and 3 common lines. * NEWS (New Features): Mention the new option. Fixes http://bugs.gnu.org/24929 --- NEWS | 2 ++ doc/coreutils.texi | 13 +++++++++++++ src/comm.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- tests/misc/comm.pl | 53 +++++++++++++++++++++++++++++++++++++---------------- 4 files changed, 97 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index 6dd6772..b3c7253 100644 --- a/NEWS +++ b/NEWS @@ -106,6 +106,8 @@ GNU coreutils NEWS -*- outline -*- ** New Features + comm now accepts the --total option to output a summary at the end. + date now accepts the --debug option, to annotate the parsed date string, display timezone information, and warn about potential misuse. diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 8110148..21fa2be 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -5144,6 +5144,19 @@ rather than the default of a single TAB character. The delimiter @var{str} may not be empty. +@item --total +Output a summary at the end. + +In the following example, @command{comm} omits the regular output +(@option{-123}), thus just printing the summary: + +@example +$ printf '%s\n' 1 2 3 4 > file1 +$ printf '%s\n' 2 3 4 5 6 > file2 +$ comm --total -123 file1 file2 +1 2 3 total +@end example + @optZeroTerminated @end table diff --git a/src/comm.c b/src/comm.c index eab8132..095ee1d 100644 --- a/src/comm.c +++ b/src/comm.c @@ -63,6 +63,9 @@ static bool issued_disorder_warning[2]; /* line delimiter. */ static unsigned char delim = '\n'; +/* If true, print a summary. */ +static bool total_option; + /* If nonzero, check that the input is correctly ordered. */ static enum { @@ -82,7 +85,8 @@ enum { CHECK_ORDER_OPTION = CHAR_MAX + 1, NOCHECK_ORDER_OPTION, - OUTPUT_DELIMITER_OPTION + OUTPUT_DELIMITER_OPTION, + TOTAL_OPTION }; static struct option const long_options[] = @@ -90,6 +94,7 @@ static struct option const long_options[] = {"check-order", no_argument, NULL, CHECK_ORDER_OPTION}, {"nocheck-order", no_argument, NULL, NOCHECK_ORDER_OPTION}, {"output-delimiter", required_argument, NULL, OUTPUT_DELIMITER_OPTION}, + {"total", no_argument, NULL, TOTAL_OPTION}, {"zero-terminated", no_argument, NULL, 'z'}, {GETOPT_HELP_OPTION_DECL}, {GETOPT_VERSION_OPTION_DECL}, @@ -137,6 +142,9 @@ and column three contains lines common to both files.\n\ --output-delimiter=STR separate columns with STR\n\ "), stdout); fputs (_("\ + --total output a summary\n\ +"), stdout); + fputs (_("\ -z, --zero-terminated line delimiter is NUL, not newline\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); @@ -263,6 +271,9 @@ compare_files (char **infiles) /* streams[i] holds the input stream for file i. */ FILE *streams[2]; + /* Counters for the summary. */ + uintmax_t total[] = {0, 0, 0}; + int i, j; /* Initialize the storage. */ @@ -317,14 +328,26 @@ compare_files (char **infiles) /* Output the line that is lesser. */ if (order == 0) - writeline (thisline[1], stdout, 3); + { + /* Line is seen in both files. */ + total[2]++; + writeline (thisline[1], stdout, 3); + } else { seen_unpairable = true; if (order <= 0) - writeline (thisline[0], stdout, 1); + { + /* Line is seen in file 1 only. */ + total[0]++; + writeline (thisline[0], stdout, 1); + } else - writeline (thisline[1], stdout, 2); + { + /* Line is seen in file 2 only. */ + total[1]++; + writeline (thisline[1], stdout, 2); + } } /* Step the file the line came from. @@ -365,6 +388,19 @@ compare_files (char **infiles) for (i = 0; i < 2; i++) if (fclose (streams[i]) != 0) die (EXIT_FAILURE, errno, "%s", quotef (infiles[i])); + + if (total_option) + { + /* Print the summary, minding the column and line delimiters. */ + char buf1[INT_BUFSIZE_BOUND (uintmax_t)]; + char buf2[INT_BUFSIZE_BOUND (uintmax_t)]; + char buf3[INT_BUFSIZE_BOUND (uintmax_t)]; + printf ("%s%s%s%s%s%s%s%c", + umaxtostr (total[0], buf1), col_sep, + umaxtostr (total[1], buf2), col_sep, + umaxtostr (total[2], buf3), col_sep, + _("total"), delim); + } } int @@ -388,6 +424,7 @@ main (int argc, char **argv) seen_unpairable = false; issued_disorder_warning[0] = issued_disorder_warning[1] = false; check_input_order = CHECK_ORDER_DEFAULT; + total_option = false; while ((c = getopt_long (argc, argv, "123z", long_options, NULL)) != -1) switch (c) @@ -423,6 +460,10 @@ main (int argc, char **argv) col_sep_len = *optarg ? strlen (optarg) : 1; break; + case TOTAL_OPTION: + total_option = true; + break; + case_GETOPT_HELP_CHAR; case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS); diff --git a/tests/misc/comm.pl b/tests/misc/comm.pl index c5cd27f..fdec3d6 100755 --- a/tests/misc/comm.pl +++ b/tests/misc/comm.pl @@ -27,37 +27,50 @@ my $prog = 'comm'; # Turn off localization of executable's ouput. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; -my @inputs = ({IN=>{a=>"1\n3"}}, {IN=>{b=>"2\n3"}}); -my @zinputs = ({IN=>{za=>"1\0003"}}, {IN=>{zb=>"2\0003"}}); +my @inputs = ({IN=>{a=>"1\n3\n3\n3"}}, {IN=>{b=>"2\n2\n3\n3\n3"}}); +my @zinputs = ({IN=>{za=>"1\0003\0003\0003"}}, + {IN=>{zb=>"2\0002\0003\0003\0003"}}); my @Tests = ( # basic operation - ['basic', @inputs, {OUT=>"1\n\t2\n\t\t3\n"} ], - ['zbasic', '-z', @zinputs, {OUT=>"1\0\t2\0\t\t3\0"} ], + ['basic', @inputs, {OUT=>"1\n\t2\n\t2\n\t\t3\n\t\t3\n\t\t3\n"} ], + ['zbasic', '-z', @zinputs, {OUT=>"1\0\t2\0\t2\0\t\t3\0\t\t3\0\t\t3\0"} ], # suppress lines unique to file 1 - ['opt-1', '-1', @inputs, {OUT=>"2\n\t3\n"} ], - ['zopt-1', '-z', '-1', @zinputs, {OUT=>"2\0\t3\0"} ], + ['opt-1', '-1', @inputs, {OUT=>"2\n2\n\t3\n\t3\n\t3\n"} ], + ['zopt-1', '-z', '-1', @zinputs, {OUT=>"2\0002\000\t3\000\t3\000\t3\000"} ], # suppress lines unique to file 2 - ['opt-2', '-2', @inputs, {OUT=>"1\n\t3\n"} ], + ['opt-2', '-2', @inputs, {OUT=>"1\n\t3\n\t3\n\t3\n"} ], + ['zopt-2', '-z', '-2', @zinputs, {OUT=>"1\000\t3\000\t3\000\t3\000"} ], # suppress lines that appear in both files - ['opt-3', '-3', @inputs, {OUT=>"1\n\t2\n"} ], + ['opt-3', '-3', @inputs, {OUT=>"1\n\t2\n\t2\n"} ], + ['zopt-3', '-z', '-3', @zinputs, {OUT=>"1\000\t2\000\t2\000"} ], # suppress lines unique to file 1 and lines unique to file 2 - ['opt-12', '-1', '-2', @inputs, {OUT=>"3\n"} ], + ['opt-12', '-1', '-2', @inputs, {OUT=>"3\n3\n3\n"} ], + ['zopt-12', '-12z', @zinputs, {OUT=>"3\0003\0003\000"} ], # suppress lines unique to file 1 and those that appear in both files - ['opt-13', '-1', '-3', @inputs, {OUT=>"2\n"} ], + ['opt-13', '-1', '-3', @inputs, {OUT=>"2\n2\n"} ], + ['zopt-13', '-13z', @zinputs, {OUT=>"2\0002\000"} ], # suppress lines unique to file 2 and those that appear in both files ['opt-23', '-2', '-3', @inputs, {OUT=>"1\n"} ], + ['zopt-23', '-23z', @zinputs, {OUT=>"1\000"} ], - # suppress all output (really?) + # suppress all output ['opt-123', '-1', '-2', '-3', @inputs, {OUT=>""} ], + # show summary: 1 only in file1, 2 only in file2, 3 in both files + ['total-all', '--total', @inputs, {OUT=>"1\n\t2\n\t2\n\t\t3\n\t\t3\n\t\t3\n" + . "1\t2\t3\ttotal\n"} ], + + # show summary only, suppressing regular output + ['total-123', '--total', '-123', @inputs, {OUT=>"1\t2\t3\ttotal\n"} ], + # invalid missing command line argument (1) ['missing-arg1', $inputs[0], {EXIT=>1}, {ERR => "$prog: missing operand after 'a'\n" @@ -128,17 +141,17 @@ my @Tests = # alternate delimiter: ',' ['delim-comma', '--output-delimiter=,', @inputs, - {OUT=>"1\n,2\n,,3\n"} ], + {OUT=>"1\n,2\n,2\n,,3\n,,3\n,,3\n"} ], # two-character alternate delimiter: '++' ['delim-2char', '--output-delimiter=++', @inputs, - {OUT=>"1\n++2\n++++3\n"} ], + {OUT=>"1\n++2\n++2\n++++3\n++++3\n++++3\n"} ], # NUL delimiter ['delim-empty', '--output-delimiter=', @inputs, - {OUT=>"1\n\0002\n\000\0003\n"} ], + {OUT=>"1\n\0002\n\0002\n\000\0003\n\000\0003\n\000\0003\n"} ], ['zdelim-empty', '-z', '-z --output-delimiter=', @zinputs, - {OUT=>"1\000\0002\000\000\0003\000"} ], + {OUT=>"1\000\0002\000\0002\000\000\0003\000\000\0003\000\000\0003\000"} ], # invalid dual delimiter ['delim-dual', '--output-delimiter=,', '--output-delimiter=+', @inputs, @@ -146,8 +159,16 @@ my @Tests = # valid dual delimiter specification ['delim-dual2', '--output-delimiter=,', '--output-delimiter=,', @inputs, - {OUT=>"1\n,2\n,,3\n"} ], + {OUT=>"1\n,2\n,2\n,,3\n,,3\n,,3\n"} ], + + # show summary, zero-terminated + ['totalz-all', '--total', '-z', @zinputs, + {OUT=>"1\000\t2\000\t2\000\t\t3\000\t\t3\000\t\t3\000" + . "1\t2\t3\ttotal\000"} ], + # show summary only (-123), zero-terminated and with ',' as delimiter + ['totalz-123', '--total', '-z123', '--output-delimiter=,', @zinputs, + {OUT=>"1,2,3,total\000"} ], ); my $save_temps = $ENV{DEBUG}; -- 2.1.4 --------------D217BF0896D64E97B4AB71C4-- From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 17 05:12:28 2016 Received: (at 24929) by debbugs.gnu.org; 17 Nov 2016 10:12:28 +0000 Received: from localhost ([127.0.0.1]:60138 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7JgC-0003SX-6Z for submit@debbugs.gnu.org; Thu, 17 Nov 2016 05:12:28 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:48864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7JgA-0003SO-GT for 24929@debbugs.gnu.org; Thu, 17 Nov 2016 05:12:27 -0500 Received: from [192.168.1.80] (unknown [109.79.107.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 13821213; Thu, 17 Nov 2016 10:12:25 +0000 (GMT) Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet To: Bernhard Voelker , =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 24929@debbugs.gnu.org References: <87twbdfvm4.fsf@jidanni.org> <74fdaf74-746e-11c3-416e-a127e19ab5cb@bernhard-voelker.de> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <80065596-34cf-c9de-1ba7-c00e18640da3@draigBrady.com> Date: Thu, 17 Nov 2016 10:12:24 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <74fdaf74-746e-11c3-416e-a127e19ab5cb@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 24929 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 17/11/16 02:51, Bernhard Voelker wrote: > On 11/12/2016 12:24 AM, 積丹尼 Dan Jacobson wrote: >> Please add [...] > >> --print-summary >> Print totals at end. >> >> --quiet >> Suppress file content output. > > Just for fun (...), I've put the requested functionality into the > attached patch. > > I'm only 60:40 for adding this to coreutils, as this may be considered > as feature creep bloating the code; OTOH the size of the additional > code it not so scaring, so I'll leave the decision up to the other CU > maintainers. > > BTW: --quiet is not needed, because you can use "-123". ;-) Usually you'd want counts separately from each other and separate from the data itself, in which case wc -l suffices: $ echo Lines in both = $(comm -12 file1 file2 | wc -l) $ echo Lines only in 1st = $(comm -23 file1 file2 | wc -l) $ echo Lines only in 2nd = $(comm -13 file1 file2 | wc -l) So this is in the efficiency/convenience category. I'm 50:50 on it (which means it goes in without further feedback). thanks for the patch! Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 17 05:18:35 2016 Received: (at 24929) by debbugs.gnu.org; 17 Nov 2016 10:18:35 +0000 Received: from localhost ([127.0.0.1]:60143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7Jm6-0003cB-S8 for submit@debbugs.gnu.org; Thu, 17 Nov 2016 05:18:35 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:52668) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7Jm5-0003by-6l for 24929@debbugs.gnu.org; Thu, 17 Nov 2016 05:18:33 -0500 Received: from [10.0.2.15] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MJYNz-1c5OlA0QF1-0033Xv; Thu, 17 Nov 2016 11:18:23 +0100 Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet To: =?UTF-8?Q?P=c3=a1draig_Brady?= , =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 24929@debbugs.gnu.org References: <87twbdfvm4.fsf@jidanni.org> <74fdaf74-746e-11c3-416e-a127e19ab5cb@bernhard-voelker.de> <80065596-34cf-c9de-1ba7-c00e18640da3@draigBrady.com> From: Bernhard Voelker Message-ID: <0edee997-d36b-2e33-c4c8-a5bb47f3e128@bernhard-voelker.de> Date: Thu, 17 Nov 2016 11:18:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <80065596-34cf-c9de-1ba7-c00e18640da3@draigBrady.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:GEsAwHsaGqkczixFq8G2LDyYSbA9YRz4SQRnAIxmKcZTNN8TmB6 e2r7MjwXmjc//F5bLVaphuArqazBx9hP80TW5Y+hBmq0rFJH0FYsZzF4cvKIfdqX9CHZNB1 WLD2MsoAi3S8Mfk4bPsqjVIT3UJmdddbejzGwCjz6e3o+JDQJpUK/f3qOximhdYVy70atNH zlF9R3eNXn5KcTekYS/TQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:LMbOm+c5n14=:QDNLDe6ohEtT7VrBMPnV+A JUwF+8w1PWK9Qm/qF0T++qPMsT5nPhQp1VdZkT5Hd0GlDtKLqOF2Vt/CiKpMx57I4KLnVqJ6d rMdvD8z850E1ifbTNYN5e0QAQ2eXu+V8U2fToFvLnYio+78JwRgo/e0BpcW4PTOO5drMIF+QE hpSNDqJ4ShRdAS/LzeEAWFK6y4dTOaf2eRGUxZ/L9cDb8EPxJ2jUTGrQtQKNXVvCvvXal7QCX p9PTaLdTsydA2i3s45s+i09xmJH4+xtBvokaroqz2s5IpH/UjT5/B73XbouwqSrsilUe7Qzsd KDygFXWlB5M7WUGRViF59YvELZmhreHlpFtw7q9XNKy7ktwH+L/q0VcvXj2q7nGpM2Rw/FSbe qdyBm4d5NFhzwWD4kEg9IVHYDVeLt24E6veB6rAXcM/bk+nKZBl8kWcsFSU6M+5iv+732XbDT vga44R0R4anSF3zzW+FyvJkMqIQ94hWvI5ggIGYXJzr67Q+8sEK1ZsEODBiZs7oUsBswHfcPA 5kFdoZeO9IGE2fbC6N6+kLCPx/04pkoPwD5apAOxl+XseunNzt0VFq7JoligbXS1L7eCigqrk 3FWj5EBPUouAfQE5pXGvTzzPMQl/50akufYf+8DkbyAm+ekf/56FL1nNbJSgPan1aqGVz1ocb DjRfcWB7V2xryGiNFhMmiFxgLnyyOAqze+fV8o4qM4qUcGPa0m0gypTlXo5BH+bAatT2IEO6e rAZGJSgRJw6NyWM8 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 24929 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 11/17/2016 11:12 AM, Pádraig Brady wrote: > Usually you'd want counts separately from each other > and separate from the data itself, in which case wc -l suffices: > > $ echo Lines in both = $(comm -12 file1 file2 | wc -l) > $ echo Lines only in 1st = $(comm -23 file1 file2 | wc -l) > $ echo Lines only in 2nd = $(comm -13 file1 file2 | wc -l) > > So this is in the efficiency/convenience category. You mean to change the --total flag to accept an argument? $ echo Lines in both = $( comm -123 --total=3 file1 file2) $ echo Lines only in 1st = $(comm -123 --total=1 file1 file2) $ echo Lines only in 2nd = $(comm -123 --total=2 file1 file2) and $ echo Lines only in 1st or 2nd = $(comm -123 --total=1,2 file1 file2) ? Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 17 05:32:19 2016 Received: (at 24929) by debbugs.gnu.org; 17 Nov 2016 10:32:19 +0000 Received: from localhost ([127.0.0.1]:60167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7JzO-0003yX-SD for submit@debbugs.gnu.org; Thu, 17 Nov 2016 05:32:18 -0500 Received: from mail.magicbluesmoke.com ([82.195.144.49]:48964) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7JzN-0003yQ-Pd for 24929@debbugs.gnu.org; Thu, 17 Nov 2016 05:32:18 -0500 Received: from [192.168.1.80] (unknown [109.79.107.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 234A0213; Thu, 17 Nov 2016 10:32:17 +0000 (GMT) Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet To: Bernhard Voelker , =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 24929@debbugs.gnu.org References: <87twbdfvm4.fsf@jidanni.org> <74fdaf74-746e-11c3-416e-a127e19ab5cb@bernhard-voelker.de> <80065596-34cf-c9de-1ba7-c00e18640da3@draigBrady.com> <0edee997-d36b-2e33-c4c8-a5bb47f3e128@bernhard-voelker.de> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Thu, 17 Nov 2016 10:32:16 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <0edee997-d36b-2e33-c4c8-a5bb47f3e128@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 24929 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 17/11/16 10:18, Bernhard Voelker wrote: > On 11/17/2016 11:12 AM, Pádraig Brady wrote: >> Usually you'd want counts separately from each other >> and separate from the data itself, in which case wc -l suffices: >> >> $ echo Lines in both = $(comm -12 file1 file2 | wc -l) >> $ echo Lines only in 1st = $(comm -23 file1 file2 | wc -l) >> $ echo Lines only in 2nd = $(comm -13 file1 file2 | wc -l) >> >> So this is in the efficiency/convenience category. > > You mean to change the --total flag to accept an argument? > > $ echo Lines in both = $( comm -123 --total=3 file1 file2) > $ echo Lines only in 1st = $(comm -123 --total=1 file1 file2) > $ echo Lines only in 2nd = $(comm -123 --total=2 file1 file2) > > and > > $ echo Lines only in 1st or 2nd = $(comm -123 --total=1,2 file1 file2) Sorry I meant if you only wanted a single count, then the existing tools suffice. Your implementation is fine as is I think. thanks, Pádraig From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 17 05:44:06 2016 Received: (at 24929) by debbugs.gnu.org; 17 Nov 2016 10:44:06 +0000 Received: from localhost ([127.0.0.1]:60172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7KAn-0004Fu-TY for submit@debbugs.gnu.org; Thu, 17 Nov 2016 05:44:06 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:53530) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7KAm-0004FI-5p for 24929@debbugs.gnu.org; Thu, 17 Nov 2016 05:44:04 -0500 Received: from [10.0.2.15] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0M371n-1cxER32JZH-00sxc6; Thu, 17 Nov 2016 11:43:54 +0100 Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet To: =?UTF-8?Q?P=c3=a1draig_Brady?= , =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 24929@debbugs.gnu.org References: <87twbdfvm4.fsf@jidanni.org> <74fdaf74-746e-11c3-416e-a127e19ab5cb@bernhard-voelker.de> <80065596-34cf-c9de-1ba7-c00e18640da3@draigBrady.com> <0edee997-d36b-2e33-c4c8-a5bb47f3e128@bernhard-voelker.de> From: Bernhard Voelker Message-ID: <400c182a-7615-97e1-4e76-03d5f89b9848@bernhard-voelker.de> Date: Thu, 17 Nov 2016 11:43:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:Y6UJVt99fGJb0PtKc9lKWkqbMfLjizYV0KnVxgv5lU8/czk1Sps FbcFoQaKt2dxxBTkfDW8YKsICSjjMh9LEyv1Kuu7OCakCqzdmemK3/BzifOx7T//rpY7Z4O Dpd99m9AXx+RZ4rZrRpMqlIy9f/7J2l4k8tZobe0ezAyIFysDC2cCjmtUuNvPQF/+l2LwA1 vdCdSkAJn54eMwu18NZ7g== X-UI-Out-Filterresults: notjunk:1;V01:K0:dc0WvISoenA=:w8xUZ2QQ0gLUI2UwvdFtAE +e7WyNCJUSJDDFsQRwotv9Zamcvshygb1wrfOK7e1a/GqUP5s01Rkf+mwyE+fb7v+VQfmQKPS EYcjhDKSvROcmx3f74PTWcF4LY1r9aki36+fd9Bm+PL5hqwHQoP/5bywOC7FIs+jgnjxC3qy9 gs5o+9AhtT23q9x1AUL2w49wmi3VGniZH3CybGbi6kMp3eRX4rDWf65kg4qZDDlTMWvEO2iRU TnNV8WSsTHd03vWBSRZDrCKUoxODoiJa8lpXHWueP7uqeaRhAuCPDB+jKP3/1X8XLeM1eM/Ar JiQWvp6BcGRwUDVYWs+8VWniMEzW9RiKL+XjjbCK7F12nj7PdZkdrsThXZRnx7LZtrZsZh/4e Wzf3EPQfqF84q48YOAe510e4alAXpUmQ3VNI8/yXK9iz4x+gbDEu7UzxHVpe3ix0SoJzrl2UA +sw5fMMpKRpOOe8tHTpXnLWPEVsC2Qz7F34vJ9jdC7eXckH5sG/Yd7emQLSpfqavTtD8YyiJR t2leaZZQumuwCkAhwyxthRFhkmfDntZPNrv6Nk4uLDxAC9QzzmIDH3teOa8VBq4OOv5/gAM7R E8L9a9Ozo+9XatuqsUbF+oq1TeHlVIGtdE5PSzFwLuo5rLHAeaz9Nr5tFad7kA5rrQdA54L8S EkEv1QRvM8u9Dv2U+QVQmEZxWZWFfD5Y8n5HziYC66DwGzJpmqA2imxiWKAxrv2lHjooW7Ih2 +sHlA/h4//DC/ZzW X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 24929 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) On 11/17/2016 11:32 AM, Pádraig Brady wrote: > Your implementation is fine as is I think. Okay, thank. As I'm only slightly pro and you are 50:50, I'll wait for someone else's opinion (/decision) whether to push. Thanks & have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 18 17:02:59 2016 Received: (at 24929) by debbugs.gnu.org; 18 Nov 2016 22:02:59 +0000 Received: from localhost ([127.0.0.1]:34264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7rFL-0007Sr-6j for submit@debbugs.gnu.org; Fri, 18 Nov 2016 17:02:59 -0500 Received: from homie.mail.dreamhost.com ([208.97.132.208]:46119 helo=homiemail-a4.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c7rFJ-0007Sj-G4 for 24929@debbugs.gnu.org; Fri, 18 Nov 2016 17:02:57 -0500 Received: from homiemail-a4.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a4.g.dreamhost.com (Postfix) with ESMTP id 8322051C07C; Fri, 18 Nov 2016 14:02:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=TdyWNGGoJ3yY+GwdMjebTpUDKhY=; b=Jthwzu1qwvsTl Le/nbX+gZ/+CdIzbcAlP+3Tr16MCZmIZWNIvphgyoB79sZoXECAryrNjqK4EFm7j Uwsn9vOHF8b2LaT9iY5Sko/+6T/3vTNdIBkGQrjpEamGVdiyUBDBj6EGnHQemjme qsvOgPHZN1KVEq3lpK4RUG7fCRulOQ= Received: from jidanni.org (61-224-88-36.dynamic.hinet.net [61.224.88.36]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a4.g.dreamhost.com (Postfix) with ESMTPSA id 51FF551C063; Fri, 18 Nov 2016 14:02:56 -0800 (PST) From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet References: <87twbdfvm4.fsf@jidanni.org> Date: Sat, 19 Nov 2016 05:43:24 +0800 Message-ID: <87lgwg79c3.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 24929 Cc: Bernhard Voelker , 24929@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) The example is confusing, as it just happens to result in 1 2 3, $ printf '%s\n' 1 2 3 4 > file1 $ printf '%s\n' 2 3 4 5 6 > file2 $ comm --total -123 file1 file2 1 2 3 total So please use $ printf '%s\n' 0 2 3 5 6 > file1 $ printf '%s\n' 1 2 4 6 7 8 9 > file2 $ comm --total -123 file1 file2 3 5 2 total Also add a note "However --total is a GNU extension. For a portable way to make totals, use wc: $ echo Lines only in 1st = $(comm -23 file1 file2 | wc -l) $ echo Lines only in 2nd = $(comm -13 file1 file2 | wc -l) $ echo Lines in both = $(comm -12 file1 file2 | wc -l) From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 22 08:14:22 2016 Received: (at 24929) by debbugs.gnu.org; 22 Nov 2016 13:14:22 +0000 Received: from localhost ([127.0.0.1]:37951 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9Aty-0006QY-EY for submit@debbugs.gnu.org; Tue, 22 Nov 2016 08:14:22 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:60914) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9Atw-0006QI-9s for 24929@debbugs.gnu.org; Tue, 22 Nov 2016 08:14:20 -0500 Received: from [10.0.2.15] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.183]) with ESMTPSA (Nemesis) id 0Lk8aY-1clGo41mBe-00c6wu; Tue, 22 Nov 2016 14:14:10 +0100 Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet To: =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , =?UTF-8?Q?P=c3=a1draig_Brady?= References: <87twbdfvm4.fsf@jidanni.org> <87lgwg79c3.fsf@jidanni.org> From: Bernhard Voelker Message-ID: <75700078-7dee-098b-98fe-70897ec8db5b@bernhard-voelker.de> Date: Tue, 22 Nov 2016 14:14:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <87lgwg79c3.fsf@jidanni.org> Content-Type: multipart/mixed; boundary="------------73FF7CFE2ECAC51DA10FAEBF" X-Provags-ID: V03:K0:kIrqp9YWQhGVPHU+94eZhohsagOpyjjic01/NQ0uHmCqB3C4T6+ v3cW4f04nkZifuh7985V9DeiGys8Fy545Rbz+CUbIuq1FRluvoFURQF+6IeIV9974unw5nn /ubWxDZk3APKlRFbqsl/6rtqZgBUOZPbIhwJAZ92qanu+lJA7KxfVCULXObLb+np6m8RPKP FOc4PJ6YUfV6I0zr+5UeQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:K7IgX5dJt5k=:7GcoodXvxjq37wn6rWUt8u f0R3PvnQh5OcZDr4jCMbaXdiipUp5R1En2A0wXPCgeDZ2jAHL6RqMCp6hLCJiRhS06OPBs6jB PqzQ0ikwWxKnveoxUezq3SOI1ukrKyU5X70k8nqVzF53A3sqNqRGOedyb/UE1rwGC+LNWf1Fa nJtypBm6mU8/RAU8t4CSB8FdwIuUTu9ZGko8Mo8eWXKNV5a1KiCooyvD6HPPzTwCQ/8jP/OCa yrlBeYfR2RgMWFg6mMQ7klmJc0oLkWqDqYuAZmyS2OownSb2VbskgHcir9PCW1xvmxlPfGr/U 6wWVLj5MT1Q4H7nr54G+jxFM8X5IP6AW8+rEZHUg+A8rLmQNtq9PEHJeaVTmoBwpyoQQ9Ipac Fxv6FO+V6knbL0RM7y8RZgQoRKir4moPsXlD2Qc1yQl1BstZTX9VqSNNmg8KsOjUSLOoBaEvl uIMQZSExCJR34S754sI1JvuayEX19R9G9v217jc+ueMssp8aUalUxHTzcpcggJxQ98XGbIg1X 4P3trp0n70SwMqhOdO3JzdAPDYb9neKOrV0cnBIeVb9LP8W03kKwTGyxwjuo/WVljmu0Ov6+T U9B+eWnyUy7VLLvCKabmMaNVG8phStUwfKyHSeWBwLhqSTHUxVl0+5AGGIL4Iv/VP/7HeQfOk U4Mdfc6Ed4mnrVw766oe9kBZn+JtNbRLgMEcqVHcsJQlEmvc/p1XvTYBP1gYmT8sIaqI= X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 24929 Cc: 24929@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) This is a multi-part message in MIME format. --------------73FF7CFE2ECAC51DA10FAEBF Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/18/2016 10:43 PM, 積丹尼 Dan Jacobson wrote: > The example is confusing, as it just happens to result in 1 2 3, > > $ printf '%s\n' 1 2 3 4 > file1 > $ printf '%s\n' 2 3 4 5 6 > file2 > $ comm --total -123 file1 file2 > 1 2 3 total > > So please use > > $ printf '%s\n' 0 2 3 5 6 > file1 > $ printf '%s\n' 1 2 4 6 7 8 9 > file2 > $ comm --total -123 file1 file2 > 3 5 2 total I see the point. I changed the example data to 'a b c ...' which I think is even easier to read and understand. > Also add a note "However --total is a GNU extension. For a portable way > to make totals, use wc: > > $ echo Lines only in 1st = $(comm -23 file1 file2 | wc -l) > $ echo Lines only in 2nd = $(comm -13 file1 file2 | wc -l) > $ echo Lines in both = $(comm -12 file1 file2 | wc -l) I'll squash in the attached, and push soon. Thanks & have a nice day, Berny --------------73FF7CFE2ECAC51DA10FAEBF Content-Type: text/x-patch; name="comm-total-doc-amendmend.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="comm-total-doc-amendmend.diff" diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 21fa2be..b0c13b9 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -5147,14 +5147,32 @@ The delimiter @var{str} may not be empty. @item --total Output a summary at the end. +Similar to the regular output, +column one contains the total number of lines unique to @var{file1}, +column two contains the total number of lines unique to @var{file2}, and +column three contains the total number of lines common to both files, +followed by the word @samp{total} in the additional column four. + In the following example, @command{comm} omits the regular output (@option{-123}), thus just printing the summary: @example -$ printf '%s\n' 1 2 3 4 > file1 -$ printf '%s\n' 2 3 4 5 6 > file2 +$ printf '%s\n' a b c d e > file1 +$ printf '%s\n' b c d e f g > file2 $ comm --total -123 file1 file2 -1 2 3 total +1 2 4 total +@end example + +This option is a GNU extension. Portable scripts should use @command{wc} to +get the totals, e.g. for the above example files: + +@example +$ comm -23 file1 file2 | wc -l # number of lines only in file1 +1 +$ comm -13 file1 file2 | wc -l # number of lines only in file2 +2 +$ comm -12 file1 file2 | wc -l # number of lines common to both files +4 @end example @optZeroTerminated --------------73FF7CFE2ECAC51DA10FAEBF-- From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 28 03:23:09 2018 Received: (at 24929) by debbugs.gnu.org; 28 Oct 2018 07:23:09 +0000 Received: from localhost ([127.0.0.1]:46425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGfPh-0003oR-Ez for submit@debbugs.gnu.org; Sun, 28 Oct 2018 03:23:09 -0400 Received: from mail-it1-f171.google.com ([209.85.166.171]:39317) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGfPf-0003o8-94; Sun, 28 Oct 2018 03:23:07 -0400 Received: by mail-it1-f171.google.com with SMTP id m15so6145476itl.4; Sun, 28 Oct 2018 00:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=Wtln1dTRTu3vIgEzt4sy20E8ZEh1CJcBHpaFjMAJR3Q=; b=UCrCVQ645mqr3QvsJ6JaVq++KE+D969y/YVO33Rck4vs2nzmCZLAC0qmAghWlVBYoX vHZ/UidI60Nt1bK1b2S6wKk3778T+G8WkGZ7k4eDDa1wnXQfc951PLTBDyAsK6X6Zsu5 xWB3vhydZ36B8Yu6+cZMPe56Kfcvi6bL2rkT1FNKx66PyviDhpw/fgHzFpnaRuNQU7Pb DVbOIzScTMyvD09qhlWYWa3z4qMUqEI+Zr4icT7RQGRf7brFMNkKOPRksje4ozMSajwp h43DMVNKchV0KP9dXkm2hIGYlY+3IBTDUu9Sn7PLSb2Vmtnv9/GHyW5QR5I9joRkLz0c E+TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Wtln1dTRTu3vIgEzt4sy20E8ZEh1CJcBHpaFjMAJR3Q=; b=B1Hn+ZVYWljMvuxaTGcomZODnFekWsgTxeY6iEsauzOn4ytfY+ES2L03qxxq0w8iOU CDa8ZC+2nL+9ThT+3Qs1FqprytmKpJavaEo6g6Z24oQyhJ10kEQfafERdByyp5qAkD0k Z7tfe0uuOmiv5q+9K3JM2jmvPqLUSLhPG5PAU2aQdI3rk7tIhvv4Y/s31UjnJmJL8QYw y0Lv/HnFzEIchzL1lQAC7SGi+EazqT3E2oh8S0vP3IF3UFujW7iTc2EuV2AI4b9mo8bs qOiL39X8nT+pgaKYZzFeG/ZxtpMLReYj0y7LFs52zTtYapS3kWAvhTSHVgYEYDmhJDJU xGhg== X-Gm-Message-State: AGRZ1gLJ6pqB0mlEm5/IGydTzAYvM2FfHpnHPbO1F1pjw1s7RgPeX9cw ufe0jtc6L/NzHXFwjMsTC/aDrLgG9zg= X-Google-Smtp-Source: AJdET5fdcf2LaFmA6x49NDuQq4pJ3pfrZtsqaow1LUFV/9OaWsmk2wZ8vWpYEbedqvb8ep2+byasnQ== X-Received: by 2002:a02:6605:: with SMTP id k5-v6mr6856296jac.96.1540711381218; Sun, 28 Oct 2018 00:23:01 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id q205-v6sm5504037itc.2.2018.10.28.00.22.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Oct 2018 00:22:59 -0700 (PDT) Subject: Re: bug#24929: comm enhancement proposal: --print-summary --quiet To: 24929@debbugs.gnu.org References: <87twbdfvm4.fsf@jidanni.org> <87lgwg79c3.fsf@jidanni.org> <75700078-7dee-098b-98fe-70897ec8db5b@bernhard-voelker.de> From: Assaf Gordon Message-ID: Date: Sun, 28 Oct 2018 01:22:58 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <75700078-7dee-098b-98fe-70897ec8db5b@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 24929 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 24929 fixed close 24929 stop (triaging old bugs) Pushed here: comm: add --total option https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=b50a151346c42816034b5c26266eb753b7dbe737 Closing as "fixed". -assaf From unknown Sat Aug 09 09:36:10 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 25 Nov 2018 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator