Skip to main content
1 of 3
lolinux
  • 13
  • 1
  • 3

find "corrupt" file, nesting an if inside a find command

I'm trying to find "corrupt" files inside a directory structure, namely files which the file command would interpret as "data". Here is the command I've been trying to run, but fails:

find . -type f -exec if [[ $(file \{} | cut -f2 -d':') == " data" ]] \; then echo " \{}  is CORRUPT" \; else echo " \{} is DATA" \; fi \;

find: paths must precede expression: then

Does anyone know what I'm doing wrong here? I realize I never saw an if inside an -exec parameter. Is it even possible?

Basically, I'm trying to find files that match that criteria (file would report it as "data", while not identifying a specific file type), and then list them, so that I can analyze before removing.

Thanks!

lolinux
  • 13
  • 1
  • 3