I wanted to recursively run chmod go+w
in a particular folder including hidden files, and I first tried
find . -name ".*" -o -name "*" -exec chmod go+w {} \;
but I found that it wasn't affecting hidden files. To check myself, I ran just
find . -name ".*" -o -name "*"
and the hidden files were listed. I also noticed that if I excluded the -o -name "*"
part it would chmod the hidden files (but exclude non-hidden of course). My last attempt was to use xargs instead
find . -name ".*" -o -name "*" | xargs chmod go+w
which finally worked as expected. What am I doing wrong in the first snippet?
Red Hat Enterprise Linux Server release 6.8 (Santiago)
GNU bash, version 4.3.42(1)-release (x86_64-unknown-linux-gnu)
find
,chmod
with-R, --recursive
could also be used right, likechmod -R go+w <dir>
? – ss_iwe May 25 '17 at 06:24find
is to understand that it doesn't find files, it evaluates expressions. It also doesn't really have distinct concepts of "tests" and "actions", they are all operations on the same level. – ilkkachu May 25 '17 at 07:02find
locates and reports dot-files by default... – Kevin Jun 22 '17 at 20:49