Skip to content

Instantly share code, notes, and snippets.

@e0da
Last active August 29, 2015 14:07
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 e0da/2d17cc1c57012c9a41f7 to your computer and use it in GitHub Desktop.
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
#!/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