Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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