From unknown Sat Jun 21 03:26:05 2025 X-Loop: help-debbugs@gnu.org Subject: bug#16618: How to show the diff command when there is a difference when comparing two files? Resent-From: Peng Yu Original-Sender: "Debbugs-submit" Resent-CC: bug-diffutils@gnu.org Resent-Date: Sat, 01 Feb 2014 19:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 16618 X-GNU-PR-Package: diffutils X-GNU-PR-Keywords: To: 16618@debbugs.gnu.org X-Debbugs-Original-To: bug-diffutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.139128288115112 (code B ref -1); Sat, 01 Feb 2014 19:28:01 +0000 Received: (at submit) by debbugs.gnu.org; 1 Feb 2014 19:28:01 +0000 Received: from localhost ([127.0.0.1]:45334 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W9gES-0003vg-L0 for submit@debbugs.gnu.org; Sat, 01 Feb 2014 14:28:01 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48605) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W9gEQ-0003vY-U5 for submit@debbugs.gnu.org; Sat, 01 Feb 2014 14:27:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9gEP-0004zp-Qj for submit@debbugs.gnu.org; Sat, 01 Feb 2014 14:27:58 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:43801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9gEP-0004zl-No for submit@debbugs.gnu.org; Sat, 01 Feb 2014 14:27:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9gEO-00010T-UG for bug-diffutils@gnu.org; Sat, 01 Feb 2014 14:27:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9gEO-0004zX-0i for bug-diffutils@gnu.org; Sat, 01 Feb 2014 14:27:56 -0500 Received: from mail-qc0-x22a.google.com ([2607:f8b0:400d:c01::22a]:64134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9gEN-0004zP-Rk for bug-diffutils@gnu.org; Sat, 01 Feb 2014 14:27:55 -0500 Received: by mail-qc0-f170.google.com with SMTP id e9so9255716qcy.29 for ; Sat, 01 Feb 2014 11:27:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=j548qDoF2H7aI1y9mZeVXI6E7bTdLq5grqGmkDsBoZo=; b=0Rj5WJCCjYcBJUqhQ6e4/xtht2rAnvLSNHBdoug4NGmoLM76L36a/Vm120QiQ5P8Sq IahXW+/lVN8Em7Vej07YWB1D1Urmw1IMlbIfZwyT/PAVEBxB9RZoEGBjKfZ65eGkTAJv 33O5KsUDlpyX4q5l06LaoXfojgQg62U9ky6Bo/2ZvAWKyFsCLUsec/8oGSmQEiHgaweF uWxKYA8Hjxl6bEtzlCgPwkN1an8K4Dm8IgQ4NI3DVKpzVYIxwIBrMZKExMay+jUqnMNM dpz9hGlK6tG2/HbKofa1lxY/JZb370V5JpAcCeR30+IhCtRFUpvCNId3zSdT36EZ2rn/ /ujg== MIME-Version: 1.0 X-Received: by 10.140.31.247 with SMTP id f110mr40028354qgf.58.1391282875393; Sat, 01 Feb 2014 11:27:55 -0800 (PST) Received: by 10.224.21.10 with HTTP; Sat, 1 Feb 2014 11:27:55 -0800 (PST) Date: Sat, 1 Feb 2014 13:27:55 -0600 Message-ID: From: Peng Yu Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -4.0 (----) Hi, The following shows that diff -r print the command e.g. "diff -r /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.wcrIdLELps/b.txt /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.AJieJ9Zk1O/b.txt" if there is an error. I'm wondering if I just compare two files, it is possible to print the diff command if there is a difference between the two files? Thanks. ~/linux/test/gnu/diffutils/diff/-r$ cat main.sh #!/usr/bin/env bash dir1=$(mktemp -d) dir2=$(mktemp -d) echo 'Hello World' > "$dir1/a.txt" echo 'Hello World' > "$dir2/a.txt" echo 'Hello World' > "$dir1/b.txt" echo 'Hello World!' > "$dir2/b.txt" #echo 'Hello World' > "$dir1/c.txt" echo 'Hello World' | gzip -n > "$dir1/c.txt.gz" diff -r "$dir1" "$dir2" ~/linux/test/gnu/diffutils/diff/-r$ ./main.sh diff -r /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.wcrIdLELps/b.txt /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.AJieJ9Zk1O/b.txt 1c1 < Hello World --- > Hello World! Only in /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.wcrIdLELps: c.txt.gz -- Regards, Peng From unknown Sat Jun 21 03:26:05 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Peng Yu Subject: bug#16618: closed (Re: How to show the diff command when there is a difference when comparing two files?) Message-ID: References: <5337AA20.7000906@cs.ucla.edu> X-Gnu-PR-Message: they-closed 16618 X-Gnu-PR-Package: diffutils Reply-To: 16618@debbugs.gnu.org Date: Sun, 30 Mar 2014 05:23:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1396156982-15000-1" This is a multi-part message in MIME format... ------------=_1396156982-15000-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #16618: How to show the diff command when there is a difference when compar= ing two files? which was filed against the diffutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 16618@debbugs.gnu.org. --=20 16618: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D16618 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1396156982-15000-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 16618-done) by debbugs.gnu.org; 30 Mar 2014 05:22:44 +0000 Received: from localhost ([127.0.0.1]:56603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WU8Ci-0003tF-2o for submit@debbugs.gnu.org; Sun, 30 Mar 2014 01:22:44 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:41873) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WU8Cf-0003t7-R7 for 16618-done@debbugs.gnu.org; Sun, 30 Mar 2014 01:22:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 4B68B39E8019; Sat, 29 Mar 2014 22:22:41 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U9SI3EKVAvpr; Sat, 29 Mar 2014 22:22:40 -0700 (PDT) Received: from [192.168.1.9] (pool-108-0-233-62.lsanca.fios.verizon.net [108.0.233.62]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id D9ACE39E8012; Sat, 29 Mar 2014 22:22:40 -0700 (PDT) Message-ID: <5337AA20.7000906@cs.ucla.edu> Date: Sat, 29 Mar 2014 22:22:40 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Peng Yu Subject: Re: How to show the diff command when there is a difference when comparing two files? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 16618-done Cc: 16618-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -2.7 (--) > I'm wondering if I just compare two files, it is > possible to print the diff command if there is a difference between > the two files? Not in diff itself, but it's easy to do from a shell script. E.g., command="diff a b" $command >output || { echo "$command" cat output } ------------=_1396156982-15000-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 1 Feb 2014 19:28:01 +0000 Received: from localhost ([127.0.0.1]:45334 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W9gES-0003vg-L0 for submit@debbugs.gnu.org; Sat, 01 Feb 2014 14:28:01 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48605) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W9gEQ-0003vY-U5 for submit@debbugs.gnu.org; Sat, 01 Feb 2014 14:27:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9gEP-0004zp-Qj for submit@debbugs.gnu.org; Sat, 01 Feb 2014 14:27:58 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:43801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9gEP-0004zl-No for submit@debbugs.gnu.org; Sat, 01 Feb 2014 14:27:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9gEO-00010T-UG for bug-diffutils@gnu.org; Sat, 01 Feb 2014 14:27:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9gEO-0004zX-0i for bug-diffutils@gnu.org; Sat, 01 Feb 2014 14:27:56 -0500 Received: from mail-qc0-x22a.google.com ([2607:f8b0:400d:c01::22a]:64134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9gEN-0004zP-Rk for bug-diffutils@gnu.org; Sat, 01 Feb 2014 14:27:55 -0500 Received: by mail-qc0-f170.google.com with SMTP id e9so9255716qcy.29 for ; Sat, 01 Feb 2014 11:27:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=j548qDoF2H7aI1y9mZeVXI6E7bTdLq5grqGmkDsBoZo=; b=0Rj5WJCCjYcBJUqhQ6e4/xtht2rAnvLSNHBdoug4NGmoLM76L36a/Vm120QiQ5P8Sq IahXW+/lVN8Em7Vej07YWB1D1Urmw1IMlbIfZwyT/PAVEBxB9RZoEGBjKfZ65eGkTAJv 33O5KsUDlpyX4q5l06LaoXfojgQg62U9ky6Bo/2ZvAWKyFsCLUsec/8oGSmQEiHgaweF uWxKYA8Hjxl6bEtzlCgPwkN1an8K4Dm8IgQ4NI3DVKpzVYIxwIBrMZKExMay+jUqnMNM dpz9hGlK6tG2/HbKofa1lxY/JZb370V5JpAcCeR30+IhCtRFUpvCNId3zSdT36EZ2rn/ /ujg== MIME-Version: 1.0 X-Received: by 10.140.31.247 with SMTP id f110mr40028354qgf.58.1391282875393; Sat, 01 Feb 2014 11:27:55 -0800 (PST) Received: by 10.224.21.10 with HTTP; Sat, 1 Feb 2014 11:27:55 -0800 (PST) Date: Sat, 1 Feb 2014 13:27:55 -0600 Message-ID: Subject: How to show the diff command when there is a difference when comparing two files? From: Peng Yu To: bug-diffutils@gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -4.0 (----) Hi, The following shows that diff -r print the command e.g. "diff -r /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.wcrIdLELps/b.txt /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.AJieJ9Zk1O/b.txt" if there is an error. I'm wondering if I just compare two files, it is possible to print the diff command if there is a difference between the two files? Thanks. ~/linux/test/gnu/diffutils/diff/-r$ cat main.sh #!/usr/bin/env bash dir1=$(mktemp -d) dir2=$(mktemp -d) echo 'Hello World' > "$dir1/a.txt" echo 'Hello World' > "$dir2/a.txt" echo 'Hello World' > "$dir1/b.txt" echo 'Hello World!' > "$dir2/b.txt" #echo 'Hello World' > "$dir1/c.txt" echo 'Hello World' | gzip -n > "$dir1/c.txt.gz" diff -r "$dir1" "$dir2" ~/linux/test/gnu/diffutils/diff/-r$ ./main.sh diff -r /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.wcrIdLELps/b.txt /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.AJieJ9Zk1O/b.txt 1c1 < Hello World --- > Hello World! Only in /var/folders/ft/9trh7jt57kqc_hyq0wm5rny40000gx/T/tmp.wcrIdLELps: c.txt.gz -- Regards, Peng ------------=_1396156982-15000-1--