I have a site, with some template directories, there are a few modules, each with their own template dir (So there are N dirs called templates
).
Each of those dirs has a dir in it, called translated
. I need a script to set all those dirs and it's contents writable.
I prefer this via a loop so I can echo the result. My shell skills are (still) very minimal, I can't seem to combine them, I can find the dirs from the current working directory, but I can't seem to get it recursive:
for f in ./*/translated/
do
echo $f
done
This only finds ./templates/translated/
, but not ./some/dirs/deeper/translated/
I can use $f
now for a chmod a+rw
, but this will only set the contents writable, how do I also get the dir itself? I need new files to be written in it too.
Summery:
1) How do I make it recursive?
2) How do I set the dir itself to +rw
?
The tool for finding stuff recursively is called find
.
find . -name 'translated' -type d -exec echo chmod -R u+rw {} +
Take out the echo
if you are satisfied with the results. If your find
does not support -exec ... +
then try with -exec ... \;
instead.
Some shells have a wildcard **
which will do the same thing, but then your script will be tied to that particular shell.