Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 May 2023 22:56:04 +0100
From:      Kaya Saman <kayasaman@optiplex-networks.com>
To:        "Ireneusz Pluta/wp.pl" <ipluta@wp.pl>, freebsd-questions@freebsd.org
Subject:   Re: Tool to compare directories and delete duplicate files from one directory
Message-ID:  <80cafa55-9609-a9ef-d739-bda1affe38df@optiplex-networks.com>
In-Reply-To: <a8518234-b777-710d-7a26-4e96fbbb404e@wp.pl>
References:  <9887a438-95e7-87cc-a162-4ad7a70d744f@optiplex-networks.com> <a8518234-b777-710d-7a26-4e96fbbb404e@wp.pl>

next in thread | previous in thread | raw e-mail | index | archive | help

On 5/4/23 18:02, Ireneusz Pluta/wp.pl wrote:
> W dniu 4.05.2023 o=C2=A017:53, Kaya Saman pisze:
>>
>> Even if I create some kind of shell script and use diff, I think it=20
>> will only compare names and not file sizes.
>
> use cmp(1)
>

This is interesting! From the man page I can see:


 =C2=A0=C2=A0=C2=A0=C2=A0 Compare file sizes of example.txt and /boot/loa=
der.conf and return=20
1 if
 =C2=A0=C2=A0=C2=A0=C2=A0 they are not equal.=C2=A0 Note that -z can only=
 be used with regular files:

 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $ cmp -z ex=
ample.txt /boot/loader.conf
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 example.txt=
 /boot/loader.conf differ: size


But*, what happens when you have thousands of files?


The man page at the top suggests compare file1 and file2, not dir1 and=20
dir2 which is what I am looking for:


NAME
 =C2=A0=C2=A0=C2=A0=C2=A0 cmp =E2=80=93 compare two files

SYNOPSIS
 =C2=A0=C2=A0=C2=A0=C2=A0 cmp [-l | -s | -x] [-bhz] [--ignore-initial=3Dn=
um1[:num2]] [--bytes=3Dnum]
 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 file1 file2 [skip1 [ski=
p2]]


 =C2=A0If it did that I would definitely say it's what I'm looking for.


I need to compare the files within:


/dir

/dir_1

/dir_2

/dir_3


where /dir_(x) are directories that have been merged into /dir....





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?80cafa55-9609-a9ef-d739-bda1affe38df>