Last active
August 29, 2015 14:22
-
-
Save rnkn/8712234baff9fd09114d to your computer and use it in GitHub Desktop.
txtdir.net script for removing non-text files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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