From nobody Thu May 04 21:56:04 2023 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QC71S2RH5z49ZpL for ; Thu, 4 May 2023 21:56:12 +0000 (UTC) (envelope-from kayasaman@optiplex-networks.com) Received: from mail.optiplex-networks.com (mail.optiplex-networks.com [212.159.80.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4QC71S1jwkz3j26 for ; Thu, 4 May 2023 21:56:12 +0000 (UTC) (envelope-from kayasaman@optiplex-networks.com) Authentication-Results: mx1.freebsd.org; none Received: from localhost (localhost [127.0.0.1]) by mail.optiplex-networks.com (Postfix) with ESMTP id 07B4A15C2C76; Thu, 4 May 2023 22:56:11 +0100 (BST) Received: from mail.optiplex-networks.com ([127.0.0.1]) by localhost (mail.optiplex-networks.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 4GbGTPAI-vAO; Thu, 4 May 2023 22:56:10 +0100 (BST) Received: from localhost (localhost [127.0.0.1]) by mail.optiplex-networks.com (Postfix) with ESMTP id 923C315C38AE; Thu, 4 May 2023 22:56:06 +0100 (BST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.optiplex-networks.com 923C315C38AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=optiplex-networks.com; s=AE93A2AC-7F67-11EA-90AE-8A1FE64F6997; t=1683237366; bh=xYubweE5Z4qsO0VkVVD3x9GySMJrTcdDCb466nrokQM=; h=Message-ID:Date:MIME-Version:To:From; b=GHJhmis5zdc/o2DOINSG8NYsQgy6ZbsyBBHmz05oMXtLEG/LKb4yrO+oXXwePBVIp E1ENAoA88VeXk+aZsSKMhGVQ3OAlR3pqU3hn+xcYzDxkyg5uztj7V0hSUqeOaKJH1K TdKVrQgn1W8lIh8fd0Zwc4nmOsdyxAsgLM9uZ1IWq/dno0wMm5jmEZMICSqYTs1iQ/ bTgA09gxyoyFG/7mYVoBRY0R7aUJWRxxvLyZbaFPm9r/ChY8ylhLs2Q3ypEq4gQLLx YbPffxjdXsEm1SeSKH6BkPYZssW5l1huGxdgQT3mbZj14w/uVe87d8ISEpBS+cecuz AjHhvd/7TFoRQ== X-Virus-Scanned: amavisd-new at mail.optiplex-networks.com Received: from mail.optiplex-networks.com ([127.0.0.1]) by localhost (mail.optiplex-networks.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ecl18SG9F6wU; Thu, 4 May 2023 22:56:06 +0100 (BST) Received: from [192.168.20.23] (unknown [192.168.20.23]) by mail.optiplex-networks.com (Postfix) with ESMTPSA id 4005F15C38AF; Thu, 4 May 2023 22:56:04 +0100 (BST) Message-ID: <80cafa55-9609-a9ef-d739-bda1affe38df@optiplex-networks.com> Date: Thu, 4 May 2023 22:56:04 +0100 List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: Tool to compare directories and delete duplicate files from one directory Content-Language: en-US To: "Ireneusz Pluta/wp.pl" , freebsd-questions@freebsd.org References: <9887a438-95e7-87cc-a162-4ad7a70d744f@optiplex-networks.com> From: Kaya Saman In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4QC71S1jwkz3j26 X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6871, ipnet:212.159.64.0/18, country:GB] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N 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....