I wrote a little script a while back that allows you to recursively change permissions on a directory tree in unix, specifying permissions for either directories or files or both.
# Outputs a list of affected directories and files.
# permissions to the default for most OSs (dirs: 755, files: 644).
Check out chmodr.sh from Gist and feel free to tinker, comment or just use as you wish.
This is VERY useful for VERY lazy people like me. Thanks!
Foudn this with google. Unfortunately, the script does not work as intended, as the getopts is executed before the PATH variable is set, so either the usage information needs to change or the PATH variable is set first and a shift operation executed so that getopts finds the options.
Does this avoid any command line string length limitations of the shell?
a space in file/directory name causes an error. Thanks for the script, it will make my life easier.
this should take care of spaces. Appeared to work.
Sounds good, I updated the gist to include your changes.
# to defined or default permissions using chmod.
echo "Usage: $0 -d DIRPERMS -f FILEPERMS PATH"
echo "PATH: path to the root directory you wish to modify permissions for"
echo " -d DIRPERMS, directory permissions"
echo " -f FILEPERMS, file permissions"
Thanks mate, I've updated the link. Should be working now.