Skip to content

Instantly share code, notes, and snippets.

@m4scosta
Created October 18, 2016 12:05
Show Gist options
  • Save m4scosta/f67d716124925198baf9f74e9946a146 to your computer and use it in GitHub Desktop.
Save m4scosta/f67d716124925198baf9f74e9946a146 to your computer and use it in GitHub Desktop.
Fast delete recursively
#!/bin/bash
ROOT=$1
for dir in $(find $ROOT* -maxdepth 5 -type d | sort -z); do
echo "Deleting $dir"
cd $dir
perl -e 'for(<*>){((stat)[9]<(unlink))}'
cd ..
rm -r $dir
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment