I have found the question How to determine if data is valid tar file without a file?, but I was wondering: is there a ready made command line solution?
相关问题
- Date with SimpleDateFormat in Java
- RegEx Max and Min length characters for a Text Box
- what's wrong in my URL validation Regex using
- jQuery validation - only show one error message
- Validation Attribute get triggered two times
相关文章
- Angular Material Stepper causes mat-formfield to v
- Why doesn't Django enforce my unique_together
- X/Html Validator in PHP
- Using CascadeMode.StopOnFirstFailure on a validato
- DDD Domain Model Complex Validation
- Laravel validator `required` fails for empty strin
- Magento, translate validation error messages
- React Native Input component takes ony numeric val
You can also check contents of *.tag.gz file using
pigz
(parallel gzip) to speedup the archive check:These are all very sub-optimal solutions. From the GZIP spec
Has to be coded into whatever language you're using.
Sometimes yes, but sometimes not. Let's see an example of a corrupted file:
It shows:
Even if you execute
tar said that there was no error:
but the file was corrupted, it has now "Fool" instead of "Pete".
What about just getting a listing of the tarball and throw away the output, rather than decompressing the file?
Edited as per comment. Thanks zrajm!
Edit as per comment. Thanks Frozen Flame! This test in no way implies integrity of the data. Because it was designed as a tape archival utility most implementations of tar will allow multiple copies of the same file!
I have tried the following command and they work well.
However, we can found these two command are time-consuming. Maybe we need some more quick way to determine the intact of the compress files.
A nice option is to use
tar -tvvf <filePath>
which adds a line that reports the kind of file.Example in a valid .tar file:
Corrupted .tar file: