BASH script for applying permissions recursively

Constantine Evans constantine at
Thu Jun 29 07:58:18 BST 2006

Dane Mutters wrote:
> 	Hello.
> 	I'm a newbie at scripting, but I think I've come up with something useful 
> that you might want to take a look at.  It's a script that can be used to 
> change the permissions of files and directories recursively, respectively.  
> It is able to handle every file name I've thrown at it, including those with 
> quotes, spaces, dashes (in any part of the filename), etc.  I could not 
> figure out how to create a file with a slash in it, so that remains untested.
> 	The reason I wrote this script is so that when somebody transfers files from 
> a vfat partition (or some other filesystem without UNIX permissions), that 
> person could then set all the permissions to something reasonable without 
> having to do it all manually.  All other solutions I found on the 'net choked 
> on either large directory structures, filenames with odd characters in them, 
> or filenames with spaces in them.
> 	Please let me know what you think about whether this is something that would 
> be useful to Ubuntu users.
> 	Thanks.
> 	--Dane
> <script attached>

Forgive me for asking, but why not just use chmod -R? I would think that 
it would be much faster and more robust than your script.

Constantine Evans

More information about the ubuntu-devel mailing list