different checksum of original file and copied file
5,588
echo -n "file" | md5sum
You are not calculating the checksum of the file, but of the filename. It is probably different because you are using two different paths (echo -n "/old/path/to/file" | md5sum
vs. echo -n "/new/path/to/file" | md5sum
).
To calculate the md5sum of the file, use this command:
md5sum file
Related videos on Youtube
Author by
Infotechie
Updated on September 18, 2022Comments
-
Infotechie almost 2 years
I am running a script that copy a file from one location to other. In script I am calculating MD5sum using below command of original file and copied file and they are different:
echo -n "file" | md5sum
How come a same file have different MD5sum? Does copy command change something in Linux? I have also checked checksum using
cksum filename
and it is also coming different. -
Infotechie over 10 yearsThanks Martin.I have one more confusion that if a file is zipped into tgz then untar it. Then the both original and untar file will also have the same checksum or different?
-
Martin von Wittich over 10 yearsIf you compare the original file with the zipped tgz file - no, they will not have the same checksum. If you extract the tgz file and compare the extracted file with the original file - yes, they must have the same checksum.