Re: compare directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, Oct 23, 2008, Bowie Bailey wrote:
>David Hlácik wrote:
>> Hello guys,
>> 
>> I have two mirrors. I need to compare files and directories on both
>> mirrors and as a result print list of those which are missing on
>> mirror 2  
>> 
>> What i did
>> 
>> find /data > find.mirror1
>> 
>> find /data > find.mirror2
>> 
>> Now i need to get list of those directories which are missing in
>> mirror1. 
>
>find /data | sort > find.mirror1
>
>find /data | sort > find.mirror2
>
>diff find.mirror1 find.mirror2

A somewhat cleaner way of doing this is to use the ``comm''
command as it generates a straight list as opposed to diff which
requires parsing the output.

cd /dir1
find . | sort > /tmp/find.mirror1
cd /dir2
find . | sort > /tmp/find.mirror2

# This will give a list of lines in mirror2 not in mirror1
comm -13 /tmp/find.mirror1 /tmp/find.mirror2 > /tmp/missingfrom1

# This will give a list of files in mirror1 not in mirror2
comm -23 /tmp/find.mirror1 /tmp/find.mirror2 > /tmp/missingfrom2

Bill
-- 
INTERNET:   bill@xxxxxxxxxxxxx  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186

Democracy must be sometihng more than two wolves and a sheep voting on what
to have for dinner -- James Bovard
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux