Re: compare directories

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



On Thu, Oct 23, 2008 at 11:53:20AM +0200, David Hláčik 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.
> 
> Thanks in advance!

I use this bash function:
dirdiff ()
{
    local src="$1" dst;
    dst="${2:-.}";
    if [ -z "$src" ]; then
        err "missing original directory";
        return 1;
    fi;
    if ! [ -d "$src" ]; then
        err "$src: not a directory";
        return 1;
    fi;
    if ! [ -d "$dst" ]; then
        err "$dst: not a directory";
        return 1;
    fi;
    diff -u <(cd "$src" && find . | LC_ALL=C sort |
      sed -e 's/^..//') <(cd "$dst" && find . | LC_ALL=C sort |
      sed -e 's/^..//')
}

-- 
lfr
0/0

Attachment: pgprSOE5GLvVy.pgp
Description: PGP signature

_______________________________________________
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