|# Recursively add a .gitignore file to all directories|
|# in the working directory which are empty and don't|
|# start with a dot. Helpful for tracking empty dirs|
|# in a git repository.|
|for i in $(find . -type d -regex ``./[^.].*'' -empty); do touch $i"/.gitignore"; done;|
This does not work recursively. It will only work for the first level of directories, assuming the shell doesn't modify the regex first, which it might since the regex is unquoted.
This is more portable.