[ccoss] Re: seeing how many files are in a directory tree --a solution

  • From: Christopher Paulin <cpaulin@xxxxxxx>
  • To: ccoss@xxxxxxxxxxxxx
  • Date: Thu, 27 Nov 2003 22:57:05 -0500

Bill wrote:

>right...that's what I get for not trying it out for rea....
>
>What I actually do is more like this:
>
>(cd src/path; find  . -type f -exec md5sum {} \; ) > src.md5sum
>(cd dest/path; find . -type f -exec md5sum {} \; ) > dest.md5sum
>diff src.md5sum dest.md5sum
>
chris@p450:/mnt/mandrake/home/chris_temp> (cd ../chris ; find  . -type f 
-exec md5sum {} \; ) > src.md5sum.bad
md5sum: ./.xsession-errors: Permission denied
md5sum: ./.kde/share/config/kdeglobals: Permission denied
md5sum: ./.kde/share/config/konquerorrc: Permission denied
md5sum: ./.kde/share/config/kdesktoprc: Permission denied
md5sum: ./.kde/share/config/konqsidebartng.rc: Permission denied
md5sum: ./.kde/share/config/kconf_updaterc: Permission denied
md5sum: ./.kde/share/config/kioslaverc: Permission denied
md5sum: ./.kde/share/config/konsolerc: Permission denied
md5sum: ./.kde/share/config/kcminitrc: Permission denied
md5sum: ./.kde/share/config/kickerrc: Permission denied
md5sum: ./.kde/share/config/klipperrc: Permission denied
md5sum: ./.kde/share/config/konq_history: Permission denied
md5sum: ./.kde/share/config/kppprc: Permission denied
md5sum: ./.kde/share/config/emaildefaults: Permission denied
md5sum: ./.kde/share/config/kscdrc: Permission denied
md5sum: ./.kde/share/config/kivio.conf: Permission denied
.........................Continued.................................
chris@p450:/mnt/mandrake/home/chris_temp> su
Password:
p450:/mnt/mandrake/home/chris_temp # (cd ../chris ; find  . -type f 
-exec md5sum {} \; ) > src.md5sum
.................takes some time to complete...............
p450:/mnt/mandrake/home/chris_temp # exit
exit
chris@p450:/mnt/mandrake/home/chris_temp> more src.md5sum
c0cdfa2dbe9f4c977b0a71fb08ddff0e  ./src/cdrtools-2.00.3.tar.gz
3ddb88cc53f78594c4f21328bb5b5325  
./src/cdrtools-2.00.3/RULES/9000-725-hp-ux-cc.rul
e695bec762e87ea36717fe5567ae1257  
./src/cdrtools-2.00.3/RULES/9000-725-hp-ux-gcc.rul
f9bb4bc951b1475b186626ba20daf67f  ./src/cdrtools-2.00.3/RULES/MKLINKS
eff219d1ad2f8f62b83df107ce323003  ./src/cdrtools-2.00.3/RULES/README
6426e135b0e2b2a68381705aeee819b1  
./src/cdrtools-2.00.3/RULES/aviion-dgux3-cc.rul
fe8c0799a6239128438584d2a69587eb  
./src/cdrtools-2.00.3/RULES/aviion-dgux3-gcc.rul
864f4d717cfa145157fe1ec6098965ae  
./src/cdrtools-2.00.3/RULES/aviion-dgux4-cc.rul
81fc31b87f3b1bb4b7fbcfcff57d8476  
./src/cdrtools-2.00.3/RULES/aviion-dgux4-gcc.rul
...........................Continued..............................

You get relative paths instead of absolute paths. The paths and md5 sums 
can both be compared.

Quoted from below:

Also copying to a Windows partition [from a different file system] changes the 
case (lower- and upper-case) of some files.

...except that would create a difference.

Christopher Paulin

>
>
>But I also usually do it the first (wrong) way first, before remembering 
>this detail!
>
>Cheers,
>
>Bill
>
>Christopher Paulin wrote:
>
>  
>
>>That solution is perfect after these changes:
>>
>>chris@p450:~> cut -f 1 -d ' ' src.md5sum > src.md5sum.cut
>>chris@p450:~> cut -f 1 -d ' ' dest.md5sum > dest.md5sum.cut
>>
>>And my actual result of the difference between the CD-ROM files and 
>>those copied to the hard drive was:
>>
>>chris@p450:~> diff src.md5sum.cut dest.md5sum.cut
>>chris@p450:~>
>>
>>No differences! I.e., the files copied byte for byte.
>>
>>The reason for the cut was:
>>
>>chris@p450:~> cat src.md5sum | more
>>94dc6e3bd83b3cc2e1d222f70498d82d  /media/cdrecorder/Autorun.ICO
>>53206fb912c7c1033a172c811cea2260  /media/cdrecorder/Autorun.INF
>>035ea2a9ed956511eb1ef3d0bc70a2fe  /media/cdrecorder/IDE/Readme.txt
>>e9f2df528fd67e5e14344e75b5e7c1df  /media/cdrecorder/IDE/SiS96x/DATA.TAG
>>8238f44e8039dc9ad1b888ff94b036d0  /media/cdrecorder/IDE/SiS96x/DATA1.CAB
>>425bb489af8c2b061e773a1abf415163  
>>/media/cdrecorder/IDE/SiS96x/DMASETUP/ATA133AP.EXE
>>bddd69c1736b33ae898df79d16109eff  
>>/media/cdrecorder/IDE/SiS96x/DMASETUP/DMA98.EXE
>>750c075251274bb44996532c77244dbb  
>>/media/cdrecorder/IDE/SiS96x/DMASETUP/HDINFO.EXE
>>b36455d752aaa0a41e3d31f8a433cd1e  
>>/media/cdrecorder/IDE/SiS96x/DMASETUP/INFINSTALL.EXE
>>98de260969d153afc66b31a48d0a2338  
>>/media/cdrecorder/IDE/SiS96x/DMASETUP/SISVSD.VXD
>>7286a38effa855e44299ef092877ea2c  
>>/media/cdrecorder/IDE/SiS96x/IDEUTIL/SISIDE.EXE
>>a7093a506c924581a5490961e18b04fd  
>>/media/cdrecorder/IDE/SiS96x/IDEUTIL/SISVSD.VXD
>>.........................................Continued........................................
>>
>>compared with:
>>
>>chris@p450:~> cat dest.md5sum | more
>>94dc6e3bd83b3cc2e1d222f70498d82d  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/Autorun.ICO
>>53206fb912c7c1033a172c811cea2260  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/Autorun.INF
>>035ea2a9ed956511eb1ef3d0bc70a2fe  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/Readme.txt
>>e9f2df528fd67e5e14344e75b5e7c1df  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/SiS96x/data.tag
>>8238f44e8039dc9ad1b888ff94b036d0  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/SiS96x/data1.cab
>>425bb489af8c2b061e773a1abf415163  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/SiS96x/dmasetup/ata133ap.exe
>>bddd69c1736b33ae898df79d16109eff  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/SiS96x/dmasetup/dma98.exe
>>750c075251274bb44996532c77244dbb  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/SiS96x/dmasetup/hdinfo.exe
>>b36455d752aaa0a41e3d31f8a433cd1e  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/SiS96x/dmasetup/INFINSTALL.EXE
>>98de260969d153afc66b31a48d0a2338  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/SiS96x/dmasetup/sisvsd.vxd
>>7286a38effa855e44299ef092877ea2c  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/SiS96x/ideutil/siside.exe
>>a7093a506c924581a5490961e18b04fd  /mnt/windows_xp/Documents and 
>>Settings/temp_cd_copy/ide/SiS96x/ideutil/sisvsd.vxd
>>.........................................Continued........................................
>>
>>Hence, the source and destination directories are different, and so 
>>there is a difference. Also copying to a Windows partition changes the 
>>case (lower- and upper-case) of some files.
>>
>>The cut utility gets the first column, which is the md5 sum, i.e, a 
>>fingerprint of the bytes in the file.
>>
>>chris@p450:~> cat src.md5sum.cut | more
>>94dc6e3bd83b3cc2e1d222f70498d82d
>>53206fb912c7c1033a172c811cea2260
>>035ea2a9ed956511eb1ef3d0bc70a2fe
>>e9f2df528fd67e5e14344e75b5e7c1df
>>8238f44e8039dc9ad1b888ff94b036d0
>>425bb489af8c2b061e773a1abf415163
>>bddd69c1736b33ae898df79d16109eff
>>750c075251274bb44996532c77244dbb
>>b36455d752aaa0a41e3d31f8a433cd1e
>>98de260969d153afc66b31a48d0a2338
>>7286a38effa855e44299ef092877ea2c
>>a7093a506c924581a5490961e18b04fd
>>.........................................Continued........................................
>>
>>Christopher Paulin
>>
>>Bill wrote:
>>
>> 
>>
>>    
>>
>>>Something I like to do in these cases is:
>>>
>>>find  src/path -type f -exec md5sum {} \; > src.md5sum
>>>find dest/path -type f -exec md5sum {} \; > dest.md5sum
>>>diff src.md5sum dest.md5sum
>>>
>>>This way, especially when a particular OS which is prone to setting a 
>>>destination file name and size before all the actual data is copied, I 
>>>will know right away which files were in fact successfully copied...
>>>
>>>Christopher Paulin wrote:
>>>
>>>
>>>
>>>   
>>>
>>>      
>>>
>>>>I copied a large number of files (including directories) and wanted to 
>>>>see if all the files were copied.
>>>>
>>>>chris@p450:~> find /media/cdrecorder/ | wc -l
>>>>2643
>>>>chris@p450:~> find /mnt/windows_xp/Documents\ and\ 
>>>>Settings/temp_cd_copy/ | wc -l
>>>>2643
>>>>chris@p450:~>
>>>>
>>>>2643 files are in each directory tree.
>>>>
>>>>I can exclude, using the not (!) symbol, directories (-type d) to list 
>>>>the number of files (non-directories) in the directory tree:
>>>>
>>>>chris@p450:~> find /media/cdrecorder/ ! -type d | wc -l
>>>>2173
>>>>chris@p450:~> find /mnt/windows_xp/Documents\ and\ 
>>>>Settings/temp_cd_copy/ ! -type d | wc -l
>>>>2173
>>>>chris@p450:~>
>>>>
>>>>I can exclude, using the not (!) symbol, files (-type f) to list the 
>>>>number of directories in the directory tree:
>>>>
>>>>chris@p450:~> find /media/cdrecorder/ \! -type f | wc -l
>>>> 470
>>>>chris@p450:~> find /mnt/windows_xp/Documents\ and\ 
>>>>Settings/temp_cd_copy/ ! -type f | wc -l
>>>> 470
>>>>chris@p450:~>
>>>>
>>>>2173 files
>>>>+470 directories
>>>>------
>>>>2643 files and directories
>>>>
>>>>Christopher Paulin
>>>>
>>>>
>>>>_______________________________________________
>>>>CCOSS mailing list
>>>>ccoss@xxxxxxxxxxxxx
>>>>CCOSS mailing list page: //www.freelists.org/cgi-bin/list?list_id=3594
>>>>CCOSS Web page: http://www.ccoss.org
>>>>
>>>>
>>>>
>>>>  
>>>>
>>>>     
>>>>
>>>>        
>>>>
>>>_______________________________________________
>>>CCOSS mailing list
>>>ccoss@xxxxxxxxxxxxx
>>>CCOSS mailing list page: //www.freelists.org/cgi-bin/list?list_id=3594
>>>CCOSS Web page: http://www.ccoss.org
>>>
>>>
>>>
>>>   
>>>
>>>      
>>>
>>_______________________________________________
>>CCOSS mailing list
>>ccoss@xxxxxxxxxxxxx
>>CCOSS mailing list page: //www.freelists.org/cgi-bin/list?list_id=3594
>>CCOSS Web page: http://www.ccoss.org
>>
>> 
>>
>>    
>>
>
>
>_______________________________________________
>CCOSS mailing list
>ccoss@xxxxxxxxxxxxx
>CCOSS mailing list page: //www.freelists.org/cgi-bin/list?list_id=3594
>CCOSS Web page: http://www.ccoss.org
>
>  
>


_______________________________________________
CCOSS mailing list
ccoss@xxxxxxxxxxxxx
CCOSS mailing list page: //www.freelists.org/cgi-bin/list?list_id=3594
CCOSS Web page: http://www.ccoss.org

Other related posts: