Skip to content

Instantly share code, notes, and snippets.

@ElectricCoffee
Created October 27, 2017 11:21
Show Gist options
  • Save ElectricCoffee/46c84a78dfbddd0ef581ef73a6faf0b0 to your computer and use it in GitHub Desktop.
Save ElectricCoffee/46c84a78dfbddd0ef581ef73a6faf0b0 to your computer and use it in GitHub Desktop.
cleanup() {
count=0
filename=$1
for file in $(find .); do
if [ -f $file ] && [[ $file =~ $filename || $file == $filename ]]; then
let "count++"
fi
done
echo "Are you sure you want to delete $count files?"
select yn in Yes No; do
case $yn in
Yes)# Skip down to the for loop below
break;;
No) echo "Okay, no files removed."
return;;
esac
done
for file in $(find .); do
if [ -f $file ] && [[ $file =~ $filename || $file == $filename ]]; then
echo removing $file
# rm $file
fi
done
echo "removed $count files"
unset count
unset filename
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment