I'd like to find
and delete all core files in some large directory tree.
To do this, I'd like to match files that satisfy a particular file name pattern, like:
find . -name 'core*'
... but once such a file is found, I also want to run the file
command on it to make sure it's really a core dump, something like:
file --brief --mime <filename> | grep -q 'application/x-coredump'
If that command succeeds, I'd like to delete the file. Can I do it all within find?
It's important that the behavior is "shortcut": I don't want to run file
unless the command matches the pattern, since that would be very slow.