GNU bug report logs - #16618
How to show the diff command when there is a difference when comparing two files?

Previous Next

Package: diffutils;

Reported by: Peng Yu <pengyu.ut <at> gmail.com>

Date: Sat, 1 Feb 2014 19:28:01 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 16618 in the body.
You can then email your comments to 16618 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-diffutils <at> gnu.org:
bug#16618; Package diffutils. (Sat, 01 Feb 2014 19:28:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Peng Yu <pengyu.ut <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-diffutils <at> gnu.org. (Sat, 01 Feb 2014 19:28:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Peng Yu <pengyu.ut <at> gmail.com>
To: bug-diffutils <at> gnu.org
Subject: How to show the diff command when there is a difference when
 comparing two files?
Date: Sat, 1 Feb 2014 13:27:55 -0600
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




Reply sent to Paul Eggert <eggert <at> cs.ucla.edu>:
You have taken responsibility. (Sun, 30 Mar 2014 05:23:02 GMT) Full text and rfc822 format available.

Notification sent to Peng Yu <pengyu.ut <at> gmail.com>:
bug acknowledged by developer. (Sun, 30 Mar 2014 05:23:02 GMT) Full text and rfc822 format available.

Message #10 received at 16618-done <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Peng Yu <pengyu.ut <at> gmail.com>
Cc: 16618-done <at> debbugs.gnu.org
Subject: Re: How to show the diff command when there is a difference when
 comparing two files?
Date: Sat, 29 Mar 2014 22:22:40 -0700
> 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
}




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 27 Apr 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 57 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.