comparing two directory structures

comparing two directory structures

Omer Zak w1 at zak.co.il
Sat Sep 4 12:43:09 IDT 2010


If you want to compare filenames, size, ownership and last update time:

  cd directory1
  ls -alR > /tmp/dirlist.1
  cd directory2
  ls -alR > /tmp/dirlist.2
  diff /tmp/dirlist.1 /tmp/dirlist.2

If you want to compare only sizes and filenames:

  cd directory1
  ls -alR | cut -d\  -f 5- > /tmp/dirlist.1
  cd directory2
  ls -alR | cut -d\  -f 5- > /tmp/dirlist.2
  diff /tmp/dirlist.1 /tmp/dirlist.2

If you want to compare only filenames:

  cd directory1
  ls -aR > /tmp/dirlist.1
  cd directory2
  ls -aR > /tmp/dirlist.2
  diff /tmp/dirlist.1 /tmp/dirlist.2



On Sat, 2010-09-04 at 12:21 +0300, Gabor Szabo wrote:
> hi,
> 
> I guess there is an obvious command for this, I just don't know it.
> 
> How can I compare two directory structures if the content is the same
> *disregarding*
> actual file content, or comparing that only if the file names and
> sizes are the same?
> 
> As I understand diff -r  would do it but it would also compare files
> line by line.
> 
> As these are images and movies, I don't want to compare them line by
> line or event byte by byte.
> As a first approximation I only want to list files that exists in one
> directory but not in the other
> or when the files have different size.

-- 
What happens if one mixes together evolution with time travel to the
past?  See: http://www.zak.co.il/a/stuff/opinions/eng/evol_tm.html
My own blog is at http://www.zak.co.il/tddpirate/

My opinions, as expressed in this E-mail message, are mine alone.
They do not represent the official policy of any organization with which
I may be affiliated in any way.
WARNING TO SPAMMERS:  at http://www.zak.co.il/spamwarning.html




More information about the Linux-il mailing list