I've just recovered tons of files (distributed in a complex directory structure, having very long names, using Unicode symbols, spaces etc in names) from a damaged hard drive. Now I'd like to verify all files which contain verification information (like zip archives (including LibreOffice and other XML-in-ZIP kind documents), 7z and rar archives, self-extracting exe arcives etc.)

How can I achieve this?


To locate files by name:

find /mount/point -type f \( \
    \( -name '*.zip' -o -name '*.o[dt][bcfghipst]' \) -exec unzip -t {} \; \
    -o -name '*.7z' -exec 7z t {} \; \
    …   \)

find /mount/point -type f \( -name '*.7z' -o -name '*.o[dt][bcfghipst]' \) -exec unzip -t {} \;

To locate files by type:

find /mount/point -type f -exec sh -c '
  case "$(file --mime-type -b - <"$0")" in
    application/zip) unzip -t "$0";;
    application/x-7z-compressed) 7z t "$0";;
    application/rar) unrar t "$0";;
' {} \;

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.