Created
November 7, 2011 13:57
-
-
Save xaptronic/1345071 to your computer and use it in GitHub Desktop.
Find empty directories and do something with them.
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
function do_if_dir_empty { | |
[ "$(ls -A $1/)" ] || eval "$2" | |
} | |
find . -type d -not \( -wholename "*/.git*" -or -wholename "*/.svn*" \) -print | while read F; do do_if_dir_empty $F "$1"; done | |
# Usage: find_empty_dirs_and_do 'echo $1 is an empty dir' | |
# Ex: find_empty_dirs_and_do 'cp /path/to/gitignore $1/.gitignore' # now this directory will be tracked by git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment