Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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";;
    …
  esac
' {} \;
share|improve this answer
add comment

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.