LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   recursive change of permissions (https://www.linuxquestions.org/questions/linux-newbie-8/recursive-change-of-permissions-163135/)

Meta42 03-27-2004 04:09 PM

recursive change of permissions
 
Hi,

I wan't to change the permissions of a folder and it's subfolders and all the files in it, but I can't figure out how to do it and get the folders and files to have different permisions from eachother?

After some man reading and googling :study: I tried first setting all to 775, and then I wanted to change all the mp3 files to 664.
so my latest atempt was:

chmod -R 775 *
ls -R | grep 'mp3' || chmod 664

But that last command did nothing

ls -R | grep 'mp3' | more

gave me a list of all the mp3 files, not sure what exactly I'm doing wrong :confused:

Is there some way of doing this, that dosn't require that I go thru thousands of files one by one ?

acid_kewpie 03-27-2004 04:12 PM

"chmod -R 755 *.mp3" should work

Tinkster 03-27-2004 04:16 PM

Or my all-time favourite, find! :)

find </start/dir/name> -iname "*mp3" -exec chmod 664 {} \;


Cheers,
Tink

Meta42 03-27-2004 04:17 PM

Quote:

Originally posted by acid_kewpie
"chmod -R 755 *.mp3" should work
Thats what I thought first to, but it dosn't seam to work since none of the folder names contains ".mp3"

chmod: failed to get attributes of `.mp3': No such file or directory

But thank you for the quick reply :)



Trying the Find command now .. *chuck chuck* ooh that took a while I have to many mp3's hehe, but it worked WEEEE!

Thank You Tinkster!

acid_kewpie 03-27-2004 04:21 PM

oh duhh.... yeah that was a stupid suggestion sorry. the *.mp3 will simply match the existing files in that directory, not a patten match for chmod. what a fool.....

listen to Tink instead.

Muzzy 03-27-2004 04:22 PM

If you want to stick with your original method - all you were missing was backticks:

chmod -R 775 `ls -R | grep 'mp3'`

or something like that *might* work. Give it a try.

Muzzy.

AutOPSY 03-27-2004 04:22 PM

*.mp3 not .mp3

Meta42 03-27-2004 04:25 PM

thx, all cli knowledge goes into my notebook, so I'll have more fun next time ;)

Tinkster 03-27-2004 04:41 PM

Quote:

Originally posted by Meta42
Trying the Find command now .. *chuck chuck* ooh that took a while I have to many mp3's hehe, but it worked WEEEE!
Yep, it would
;)

Quote:

Thank You Tinkster!
Anytime :}


Cheers,
Tink


All times are GMT -5. The time now is 12:36 PM.