Posted By

jfine on 10/14/10


Tagged

file files chmod find xargs 644


Versions (?)

Chmod files recursively to 644


 / Published in: Bash
 

-print0 and -0 are used to allow for spaces and other wacky chars in file names

  1. find . -type f -print0 | xargs -0 chmod 644

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: laforge on October 14, 2010

You can try directly this:

find . -type f -exec chmod 644 '{}' \;

Posted By: jfine on May 24, 2012

That would work unless there are some really wacky filenames. That's the main reason I'm using the -print0 pattern.

See this URL for more info: http://www.gnu.org/software/findutils/manual/htmlnode/findhtml/Problems-with-_002dexec-and-filenames.html

Posted By: jfine on May 24, 2012

xargs is also much faster.

Here are a couple other interesting links for those who care to dig deeper.
Linux: xargs vs. exec {}
find -exec cmd {} + vs | xargs

You need to login to post a comment.