Skip to content

Instantly share code, notes, and snippets.

@euperia
Created May 26, 2017 08:03
Show Gist options
  • Save euperia/f9df2d36f26a999549e173245ea27a28 to your computer and use it in GitHub Desktop.
Save euperia/f9df2d36f26a999549e173245ea27a28 to your computer and use it in GitHub Desktop.
Remove files that are not what they appear to be
#!/bin/sh
# Some image files were fetched from an URL and not validated.
# Hence we have files that have '.jpg' extensions but are actually HTML files.
# Clean these out
# Remove the `-i` from the `rm` if you don't want to manually confirm deletion
for f in `find ./ -type f -iname "*.jpg"`;
do
file "$f" | grep -q HTML
if [ $? -eq 0 ] ; then
echo "Deleting $f"
rm -i "$f"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment