From owner-freebsd-questions@FreeBSD.ORG Wed Sep 12 18:25:41 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 705B51065670 for ; Wed, 12 Sep 2012 18:25:41 +0000 (UTC) (envelope-from vogelke@hcst.net) Received: from beta.hcst.com (beta.hcst.com [192.52.183.241]) by mx1.freebsd.org (Postfix) with ESMTP id 2EEDF8FC12 for ; Wed, 12 Sep 2012 18:25:41 +0000 (UTC) Received: from beta.hcst.com (localhost [127.0.0.1]) by beta.hcst.com (8.14.3/8.14.3/Debian-9.4) with ESMTP id q8CIL0XP002054 for ; Wed, 12 Sep 2012 14:21:00 -0400 Received: (from vogelke@localhost) by beta.hcst.com (8.14.3/8.14.3/Submit) id q8CIL05N002053; Wed, 12 Sep 2012 14:21:00 -0400 Received: by kev.msw.wpafb.af.mil (Postfix, from userid 32768) id 77E05BEA6; Wed, 12 Sep 2012 14:11:05 -0400 (EDT) To: freebsd-questions@freebsd.org In-reply-to: <20120912011725.GG3066@hs1.VERBENA> (message from Colin Barnabas on Tue, 11 Sep 2012 18:17:25 -0700) Organization: Array Infotech X-Disclaimer: I don't speak for the USAF or Array Infotech. X-GPG-ID: 1024D/711752A0 2006-06-27 Karl Vogel X-GPG-Fingerprint: 56EB 6DBF 4224 C953 F417 CC99 4C7C 7D46 7117 52A0 References: <20120911213804.GA9817@ethic.thought.org> <20120912011443.5df17cf2.freebsd@edvax.de> <20120912002408.GA10496@ethic.thought.org> <20120912011725.GG3066@hs1.VERBENA> Message-Id: <20120912181105.77E05BEA6@kev.msw.wpafb.af.mil> Date: Wed, 12 Sep 2012 14:11:05 -0400 (EDT) From: vogelke+freebsd@pobox.com (Karl Vogel) Subject: Re: cksum entire dir?? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: vogelke+freebsd@pobox.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Sep 2012 18:25:41 -0000 >> On Tue, 11 Sep 2012 14:38:04 -0700, Gary Kline wrote: G> I'm trying to checksum directories as I move them around. ive read the G> man page for sum and cksum ... or maybe skimmed them. no joy. anybody G> know of a utility to do this? I've got files that are decades old... I wouldn't use CRC32 to check file integrity; use SHA1 or MD5 at the very least. See http://home.comcast.net/~bretm/hash/8.html for details. >> On Tue, 11 Sep 2012 18:17:25 -0700, >> Colin Barnabas replied: Are you by any chance a "Dark Shadows" fan? C> This works for me: C> $ find foo/ -type f -print0 | xargs -0 md5 >> foo.md5 I do something similar when copying files to a backup server; it's not unheard of for SSH to drop a session or a drive to have a bad spot. An easy-to-automate way is: get a list of files, use the hash of your choice to generate signatures, sort the signature file by the hash, and then get the hash value of the signature file. Here's an example using my bin directory: me% ls aline dir hist makecfg mx ro authlog diskused isodate makekey mylook setperm avg dline kernlog makepass n32 sha buildenv dnslog lastdom mb n64 sshlog cline dosrc linkdups md5path nr sulog cmdlog dot ll memuse ntplog syslog conlog dp lsl mgrep pathinfo tc core f lslm mk ping tcv cronlog fixhist lsn mkdtree plog tl daemonlog fmt lsnm mkproto pwgen tr0 dblog getperm lss mkrcs r tx dbrun google lssm mongolog rand vi dh haval lst month range zp dig help2man lstm mv2inode me% find . -type f -print0 | xargs -0 md5 -r | sort > /tmp/dir.md5 me% cat /tmp/dir.md5 01328aeb4fd0eb3d998f4d7ad407a73f ./setperm 017d6d622fb93bf7f23c0fb7b96b16eb ./core 0287839688bd660676582266685b05bd ./mkrcs 0b97494883c76da546e3603d1b65e7b2 ./pwgen ... ddbed53e795724e4a6683e7b0987284c ./authlog ddbed53e795724e4a6683e7b0987284c ./cmdlog ddbed53e795724e4a6683e7b0987284c ./conlog ddbed53e795724e4a6683e7b0987284c ./cronlog ddbed53e795724e4a6683e7b0987284c ./daemonlog ddbed53e795724e4a6683e7b0987284c ./kernlog ddbed53e795724e4a6683e7b0987284c ./ntplog ddbed53e795724e4a6683e7b0987284c ./sulog ddbed53e795724e4a6683e7b0987284c ./syslog ... fdff1fd84d47f76dbd4954c607d66714 ./dbrun ff5e24efec5cf1e17cf32c58e9c4b317 ./tr0 The *log files are hard-linked, hence the duplicate MD5 values. me% md5 -r /tmp/dir.md5 fdc34a5a5df7807d4fc45739d2d3039f /tmp/dir.md5 If I copy these files elsewhere, I can repeat the steps and just compare the final hash; if it's anything other than 'fdc34...3039f', something's wrong. -- Karl Vogel I don't speak for the USAF or my company When In Doubt, Empty The Magazine --bumper-sticker seen on military base