Skip to content

Instantly share code, notes, and snippets.

@djcp
Created February 14, 2014 18:32
Show Gist options
  • Save djcp/9006375 to your computer and use it in GitHub Desktop.
Save djcp/9006375 to your computer and use it in GitHub Desktop.
Randomly sample files recursively from PWD to test for mime-types
#!/bin/bash
COMMAND='RAND=`shuf -n 1 -i 1-100`;
if [ $RAND = 1 ]; then
if [ -e "{}" ]; then
MIME_TYPE=`file -b --mime-type "{}"`
echo "$MIME_TYPE\t\t => {}"
if [ "$MIME_TYPE" = "" ]; then
echo "******************";
echo "{} HAD AN EMPTY MIME TYPE"
echo "******************";
fi
fi
fi'
find -type f -print0 | xargs -0 -I '{}' sh -c "$COMMAND"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment