Re: comparing two directory structures
On Sun, Sep 5, 2010 at 5:36 PM, Ehud Karni e...@unix.mvs.co.il wrote: On Sat, 4 Sep 2010 12:21:40, Gabor Szabo wrote: 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. I had the same problem, so I patched diff to do it. I added 2 switches -Z: compare by siZe only, -M: different Modification time is a difference. For a full description with the patches see: http://www.mail-archive.com/bug-diffut...@gnu.org/msg00023.html As these are images and movies, I don't want to compare them line by line or event byte by byte. Seems very common these days. Very nice. I could not find it out from the archive, has it been accepted? Gabor ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: comparing two directory structures
On Mon, 6 Sep 2010 09:03:52 Gabor Szabo wrote: Very nice. I could not find it out from the archive, has it been accepted? No. I got no reply from the diffutil maintainer. Ehud. -- Ehud Karni Tel: +972-3-7966-561 /\ Mivtach - Simon Fax: +972-3-7976-561 \ / ASCII Ribbon Campaign Insurance agencies (USA) voice mail and X Against HTML Mail http://www.mvs.co.il FAX: 1-815-5509341 / \ GnuPG: 98EA398D http://www.keyserver.net/Better Safe Than Sorry ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: comparing two directory structures
On Mon, Sep 6, 2010 at 1:34 PM, Ehud Karni e...@unix.mvs.co.il wrote: On Mon, 6 Sep 2010 09:03:52 Gabor Szabo wrote: Very nice. I could not find it out from the archive, has it been accepted? No. I got no reply from the diffutil maintainer. Maybe you need to send it as a new e-mail with [PATCH] in the subject? Gabor ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: comparing two directory structures
On Sat, 4 Sep 2010 12:21:40, Gabor Szabo wrote: 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. I had the same problem, so I patched diff to do it. I added 2 switches -Z: compare by siZe only, -M: different Modification time is a difference. For a full description with the patches see: http://www.mail-archive.com/bug-diffut...@gnu.org/msg00023.html As these are images and movies, I don't want to compare them line by line or event byte by byte. Seems very common these days. Ehud. -- Ehud Karni Tel: +972-3-7966-561 /\ Mivtach - Simon Fax: +972-3-7976-561 \ / ASCII Ribbon Campaign Insurance agencies (USA) voice mail and X Against HTML Mail http://www.mvs.co.il FAX: 1-815-5509341 / \ GnuPG: 98EA398D http://www.keyserver.net/Better Safe Than Sorry ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: comparing two directory structures
I like the rsync solution - it is what I was going to suggest. On Sun, Sep 5, 2010 at 5:36 PM, Ehud Karni e...@unix.mvs.co.il wrote: On Sat, 4 Sep 2010 12:21:40, Gabor Szabo wrote: 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. I had the same problem, so I patched diff to do it. I added 2 switches -Z: compare by siZe only, -M: different Modification time is a difference. For a full description with the patches see: http://www.mail-archive.com/bug-diffut...@gnu.org/msg00023.html As these are images and movies, I don't want to compare them line by line or event byte by byte. Seems very common these days. Ehud. -- Ehud Karni Tel: +972-3-7966-561 /\ Mivtach - Simon Fax: +972-3-7976-561 \ / ASCII Ribbon Campaign Insurance agencies (USA) voice mail and X Against HTML Mail http://www.mvs.co.il FAX: 1-815-5509341 / \ GnuPG: 98EA398D http://www.keyserver.net/Better Safe Than Sorry ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
comparing two directory structures
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. Gabor ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: comparing two directory structures
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 ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: comparing two directory structures
Gabor Szabo szab...@gmail.com writes: 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 about adding -q or --brief to diff -r? Will that not do the trick for you? If diff options don't do the job for whatever reason then, given that you are only interested in file names and sizes, maybe some cheating (compare directory listings rather than files themselves) shell sorcery like (bash syntax) function shortlist() { /bin/ls -l $1 | /bin/awk '{print $5 $8}'; } function shortdiff() { /usr/bin/diff -u (shortlist $1) (shortlist $2); } or similar will be good enough? For more generality, you may try function shortlist() { /bin/find $1 -type f -ls | /bin/awk '{print $7 $NF}' } instead of the above. -- Oleg Goldshmidt | p...@goldshmidt.org ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il
Re: comparing two directory structures
Hi Gabor, You can use rsync. rsync -avn a b -n is the flag for dry-run. If you add the flag -c then it will compute the checksum for every file. If -c is not used, then it will relay on timestamp and size of file for comparison. output: $ rsync -avn a b sending incremental file list a/ a/file sent 74 bytes received 19 bytes 186.00 bytes/sec total size is 23.29K speedup is 250.47 (DRY RUN) Investigate the -q option if you want to use this command from a script. Regards, Kfir On Sat, Sep 4, 2010 at 12:21 PM, Gabor Szabo szab...@gmail.com 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. Gabor ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il ___ Linux-il mailing list Linux-il@cs.huji.ac.il http://mailman.cs.huji.ac.il/mailman/listinfo/linux-il