LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   combining find with chmod, but doesn't work... (https://www.linuxquestions.org/questions/linux-newbie-8/combining-find-with-chmod-but-doesnt-work-708380/)

marvelade 03-01-2009 10:46 AM

combining find with chmod, but doesn't work...
 
Hi all,

I found a thread on this forum telling me how to chmod directories separately from files.

Quote:

find [YOURDIR] -type d | chmod 755 [files] \;

find [YOURDIR] -type f | chmod 644 [files] \;
In my case I want all subdirectories of the dir I'm in, to be 766, and all files must be 040 (long story why they need to be like this ;) ).

I issued this command:

Code:

find ./ -type f | chmod -R 040 *
but instead of chmod'ing only the files, it alters everything; directories too.

What am I doing wrong? could it be the -R parameter of chmod?



best regards,
Marvelade

TBC Cosmo 03-01-2009 11:02 AM

Since find will march down the dir structure and give you all files (type f), there's no need for the recursive option to chmod.

Code:

find . -type f -exec chmod 040 {} \;


All times are GMT -5. The time now is 05:59 AM.