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

link|improve this question
feedback

1 Answer

up vote 0 down vote accepted

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.

link|improve this answer
Hello Zored, Thanks for quick answer. yes script saved my time. Thank You, – Bharathvn Jan 20 '11 at 9:49
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.