I gzip a folder, transfer it to a remote location and then extract it to a folder. The problem is that this machine is a little unreliable and sometimes writes don't succeed and there can be zero-byte files or corrupted files (I verified the archive was correct and subsequent extractions worked fine).

I know that gzip files have CRC info in them, so I'm wondering if there's an easy way to do this:

  1. Download gzip
  2. Extract gzip
  3. Compare files on disk to gzip CRCs to verify extraction succeeded

gzip already checks it.

if ! gunzip FILENAME 
  echo "crc error"
  • I'm having a lot of trouble confirming what you're saying. I can't see any docs which show that. I don't want to check that the file is valid within the archive, I wanted to check that the file on disk matches what is in the archive.
    – Chaos
    Nov 9 '15 at 22:43
  • huh? gzip is not an archive.
    – Jasen
    Nov 11 '15 at 1:05
  • returning non-zero (which means false) on error is pretty standard for all *nix commands. gzip follows that
    – Jasen
    Nov 11 '15 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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