Re: Trying to compare files in two directories with checksum
- From: Cyrus Kriticos <cyrus.kriticos@xxxxxxxxxxxxxx>
- Date: Thu, 14 Feb 2008 20:48:22 +0100
EyeHaveNoName wrote:
On Feb 14, 1:23 pm, Cyrus Kriticos <cyrus.kriti...@xxxxxxxxxxxxxx>
wrote:
EyeHaveNoName wrote:
I have a need to go through about 6TB of data and compare the files insum1=$(md5sum -b "/mount/directory/file1")
one directory to the files in another. The need arose because all of
these files were copied from point A to point B, and now we need to
validate that there has been no corruption. I am thinking that cksum
will work, these are graphics files.
I understand how to find all the files and run a command on them, but
I am at a loss as to how I can :
1) For each file name in /mount/directory...
2) Compare that file with the same name in /other_mount/directory
using cksum. i.e.
$ cksum /mount/directory/file1 /other_mount/directory/file1
sum2=$(md5sum -b "/other_mount/directory/file1")
if [ "${sum1% *}" = "${sum2% *}" ]; then echo ok; else echo not ok; fi
--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
Thanks, this is helpful. But I am not sure it will work for me. This
only works when I know the file name; there are thousands (or millions
for all I know) of files in these directories that need to be parsed,
and they are all under fairly deep directory structures. I suppose I
could run a find on each dir. first, then feed the output into this?
You wrote "I understand how to find all the files and run a command on them".
--- comparefiles.sh ---
#!/bin/bash
prefix1="/mount/directory/file1" # without trailing /
prefix2="/other_mount/directory/file1" # without trailing /
find "$prefix1" -type f | while read filename; do
name="${filename#$prefix1*}"
sum1="$(md5sum -b "$prefix1$name")"
sum2="$(md5sum -b "$prefix2$name")"
if [ "${sum1% *}" = "${sum2% *}" ]; then
echo "ok: $prefix1$name"
else
echo "not ok: $prefix1$name"
fi
done
--- comparefiles.sh ---
--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
.
- References:
- Trying to compare files in two directories with checksum
- From: EyeHaveNoName
- Re: Trying to compare files in two directories with checksum
- From: Cyrus Kriticos
- Re: Trying to compare files in two directories with checksum
- From: EyeHaveNoName
- Trying to compare files in two directories with checksum
- Prev by Date: Re: Trying to compare files in two directories with checksum
- Next by Date: Re: Trying to compare files in two directories with checksum
- Previous by thread: Re: Trying to compare files in two directories with checksum
- Next by thread: Re: Trying to compare files in two directories with checksum
- Index(es):
Relevant Pages
|