Monday, May 20, 2013

Remove absolute path from MD5 file

The following command will remove absolute paths from a md5 file :
  sed -i -r "s/ .*\/(.+)/  \1/g" file.md5  
This is quite useful when you download backup files which have MD5 containing absolut paths.

For example :
 $ cat file.md5  
 8ee6e966f2cb7a84620ed137604e00c5 /data/prod/file  

If you want to check this file on another server, you won't be able to do it unless you put the data file in the exact same directory (/data/prod/).

After running the above sed command, your md5 file will look like :
 $ cat file.md5  
 8ee6e966f2cb7a84620ed137604e00c5 file  

You can then check your md5 print with "md5sum -c file.md5". You just need to have the MD5 file in the same directory as the data file.

1 comment: