Skip to content

Instantly share code, notes, and snippets.

@rnkn
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnkn/8712234baff9fd09114d to your computer and use it in GitHub Desktop.
Save rnkn/8712234baff9fd09114d to your computer and use it in GitHub Desktop.
txtdir.net script for removing non-text files
#! /bin/sh
usage="Usage: ssweeper -c
\nWARNING: this will remove all files in /usr/home/* that do not match
\ntypes directory, empty or text"
if [[ $1 = "-c" ]]
then
find /usr/home/* | while read file
do
if file -b "$file" | grep -q -v 'directory\|empty\|.*text.*'
then
echo "$file" # log with syslog instead
rm "$file"
fi
done
else
echo $usage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment