Last active
August 29, 2015 14:07
-
-
Save e0da/2d17cc1c57012c9a41f7 to your computer and use it in GitHub Desktop.
rsync-ing an empty directory is waaayyyy faster than rm or find -exec or find -delete
This file contains 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 | |
readonly empty_dir=$(mktemp -d) | |
readonly target="$1" | |
rm -rf $empty_dir | |
mkdir $empty_dir | |
rsync --recursive --delete $empty_dir/ "$target"/ | |
rmdir $empty_dir "$target" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment