Saturday, October 4, 2008 at 12:40 pm
find magic: recursive delete and chmod
You can do a lot of cool things with find combined with the -exec parameter:
- recursive chmod of only directories
find . -type d -exec chmod 755 {} \; - recursive chmod of only files
find . -type f -exec chmod 644 {} \; - recursive delete of all txt files
find . -name '*.txt' -exec rm {} \;
(edited due to popular demand.)


No. 1 — October 4th, 2008 at 3:28 pm
*.txt escapen nicht vergessen.
Also entweder:
find . -name \*.txt -exec rm {} \;
oder:
find . -name ‘*.txt’ -exec rm {} \;
No. 2 — October 7th, 2008 at 5:38 pm
sorry that i must now correct you…
we build se directory lik thiz:
$ find
.
./mysql.txt
./la
./la/mysql1.txt
now me make tha find:
$ find . -iname mysql*
./mysql.txt
ups … now we know, that bash makes:
$ find . -iname mysql*
to
$ find . -iname mysql.txt
ok, got it mate? :) of course, if there is no file/directory matching your expression in $PWD, it operates as “expected”.
cheers,
ps: GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu); debian etch