BASH script for applying permissions recursively

Dan Kegel dank at kegel.com
Thu Jun 29 23:15:44 BST 2006


On 6/29/06, Micah J. Cowan <micah at cowan.name> wrote:
> Sounds like a bug in find. I think fixing the bug in find would be
> preferable to using a new script.

I don't think there's a bug in find.
I assume the original poster was confused, and was doing something like
$ find . -print | xargs chmod
that will fail on filenames with spaces.
If you like xargs, and need to handle arbitrary filenames, you should
use the -print0 option
to find and the -0 option to xargs.


FWIW, here are a couple handy find commands
that I use to propagate read and execute bits from user to group and world.

$ find . -perm -400 -not -perm -044 -print0 | xargs -0
--no-run-if-empty chmod ag+r
$ find . -perm -100 -not -perm -011 -print0 | xargs -0
--no-run-if-empty chmod ag+x
- Dan



More information about the ubuntu-devel mailing list