Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.unix.shell > #14026

Re: Comparing Binary Files

From Ivan Shmakov <ivan@siamics.net>
Newsgroups comp.unix.shell
Subject Re: Comparing Binary Files
Date 2016-10-04 18:02 +0000
Organization Aioe.org NNTP Server
Message-ID <87k2doxa9a.fsf@violet.siamics.net> (permalink)
References <c32a379b-4a92-41ac-b59d-e6daffa4a860@googlegroups.com> <nssq4m$u9d$1@news-1.m-online.net>

Show all headers | View raw


>>>>> Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
>>>>> On 03.10.2016 06:52, lawrencedo99@gmail.com wrote:

[...]

 >> diff -u <(xxd /dev/dvd) <(xxd disc.iso)

 >> to compare hex dumps of the files instead.

 >> This works great--for example, showing me that the only difference
 >> is a few extra sectors of zero padding at the end of the disc.

 > That does not seem to be a satisfying solution in the general case;
 > even simple byte offsets by a few additional bytes at the beginning
 > of one file will show the whole files differing.  In that case a
 > "binary files differ" message would be preferable.  For the case of
 > changed bytes or additional data at the end of one file it's okay.

	As would be $ cmp -l, I suppose.

 >> However, it seems to use a lot of memory, even when no differences
 >> are found...

 > Why?  You are creating just to more processes and the shell
 > establishes two pipes for the diff.  I would not expect "a lot"
 > memory demand for that.

	Two reasons I can readily think of:

	* xxd(1) can easily turn a 4.5 GB DVD+R image into a 20+ GB
	  hexdump;

	* upon seeing that the files are indeed "binary", diff(1) may
	  refrain from running a memory-costly LCS algorithm and resort
	  to "exit (1) on the first byte that differs; exit (0) if none"
	  behavior that costs virtually no memory at all.

-- 
FSF associate member #7257  58F8 0F47 53F5 2EB2 F6A5  8916 3013 B6A0 230E 334A

Back to comp.unix.shell | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Comparing Binary Files lawrencedo99@gmail.com - 2016-10-02 21:52 -0700
  Re: Comparing Binary Files Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-10-03 07:25 +0200
    Re: Comparing Binary Files lawrencedo99@gmail.com - 2016-10-02 22:48 -0700
      Re: Comparing Binary Files Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-10-03 09:12 +0200
        Re: Comparing Binary Files lawrencedo99@gmail.com - 2016-10-05 00:18 -0700
    Re: Comparing Binary Files Ivan Shmakov <ivan@siamics.net> - 2016-10-04 18:02 +0000
      Re: Comparing Binary Files lawrencedo99@gmail.com - 2016-10-04 11:32 -0700
      Re: Comparing Binary Files Janis Papanagnou <janis_papanagnou@hotmail.com> - 2016-10-05 10:01 +0200
        Re: Comparing Binary Files Ivan Shmakov <ivan@siamics.net> - 2016-10-07 12:30 +0000
  Re: Comparing Binary Files Rakesh Sharma <sharma__r@hotmail.com> - 2016-10-04 03:03 -0700
  Re: Comparing Binary Files Michael Paoli <michael1cat@yahoo.com> - 2016-10-06 01:32 -0700
    Re: Comparing Binary Files lawrencedo99@gmail.com - 2016-10-06 14:42 -0700

csiph-web