ooo
ooo

Reputation: 743

MD5 check of copied files given their original hash and second directory where they were copied

I am migrating a list of files to a new place and part of the process is to check if they were correctly copied before deleting original files.

Initially I have a list.txt that has absolute paths to original files and I generate a file that has md5 of original files:

    d41d8cd98f00b204e9800998ecf8427e  /dir1/file

Now I need to validate these hashes against the hashes of files in second directory.

My approach is to first change /dir1 to /dir2 in the text file then run:

      md5sum -c list.txt

My question: Is there a way to run this last command without having to manually change all strings in list.txt to point to dir2:

Upvotes: 1

Views: 1040

Answers (1)

tink
tink

Reputation: 15205

This should work for you (assuming you're sitting in the right place in the filesystem):

sed 's/dir1/dir2/' list.txt | md5sum -c 

Upvotes: 2

Related Questions