0

I need a help on untaring a file when checksum matches.

Here is the scenario.

i have a tar file and its check sum is dfsafdafsafasfsaf232, stored in a checksum file and need a script to match this checksum file and extract to specific folder when matches.

Thanks in advance

Bharathvn
  • 15
  • 3

1 Answers1

0

Should be as easy as something like this.

md5sum --status --check checksumfile.md5
if [ $? -ne 0 ]; then
   echo >&2 "MD5 Failed"
   exit 1
else
  tar -xzf filename.tar.gz
fi

Of course if you aren't using md5sum/sha*sum, then you may need to see if your checksum tool has a check mode, that returns the results as the error level.

Zoredache
  • 128,755
  • 40
  • 271
  • 413