LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-02-2004, 12:29 AM   #1
bluefire
Member
 
Registered: Oct 2003
Distribution: Mandrake 10
Posts: 160

Rep: Reputation: 30
recursive yet selective chmod


I would like to do something like:

chmod -R 664 pics

However, the above command also alters the flags for directories; I want to avoid changing the attributes of the directories.

(The reason I'm doing this is that Rox-Filer generates thumbnails only for image files that do not have executable bits set; therefore I wish to chmod my pics folder tree, and remove the executable bits from all image files. If I remove the executable bits from folders, however, I can no longer open them.)
 
Old 05-02-2004, 12:31 AM   #2
hallamigo
Member
 
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230

Rep: Reputation: 31
Try 'chmod /*/*.jpg' and add an asterisk and slash for each level.
 
Old 05-02-2004, 12:32 AM   #3
hallamigo
Member
 
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230

Rep: Reputation: 31
oops, 'chmod 664 /*/*.jpg'
 
Old 05-02-2004, 12:56 AM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Or
find -type f -exec chmod 664 {} \;
should do it.

-- (From the top of the directories you want to recursively change - not from / or anything. )
 
Old 05-02-2004, 12:22 PM   #5
bluefire
Member
 
Registered: Oct 2003
Distribution: Mandrake 10
Posts: 160

Original Poster
Rep: Reputation: 30
Thanks for the responses. Digiot - what's the \; at the end for?
 
Old 05-02-2004, 01:34 PM   #6
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
I don't really know - find just requires it for its syntax. It marks the end of arguments to whatever is exec'ed. As guesses, possibly since you're issuing two commands, in a sense, you need both the semi-colon as a 'line separator' and a newline. The first tells find you're done with chmod and the second tells bash you're done with find. Or, going another way, the semi-colon lets find tell chmod its done when find execs it. The '{}' is substituted with filenames by find and the ';' actually tells chmod it can execute. Maybe the command is actually 'chmod file1 ; chmod file2 ; chmod file 3...' with the semi-colon being inserted on each file that returns 0 from the type test when 'chmod file1 chmod file2' would be an error. (The backslash is just escaping the semi-colon, of course.) Last shot is that it's just some kind of getopt() requirement. It'd take seeing (and understanding) the source code to really say, I guess. Somebody who can do that should be able to say for sure.

Last edited by slakmagik; 05-02-2004 at 01:35 PM.
 
Old 10-22-2004, 06:25 PM   #7
thegnu
Member
 
Registered: May 2004
Location: St. Petersburg, FL USA
Distribution: Arch Linux, Fedora Core 3
Posts: 51

Rep: Reputation: 15
Oooo!!! this find stuff is exciting! My life has been horrible since I had all my music on an NTFS partition before I bailed on Windows, and everthing was executable, and I did a chmod -r to unexecutable them, and fuckit if I could see inside directories anymore.

Thank heavens!

A penguin For posterity
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] FTP: recursive chmod (separate for directories and files) mgmax Linux - Software 11 01-29-2011 08:06 AM
Help with a recursive chmod script in bash lowpro2k3 Programming 11 07-25-2005 07:03 PM
chmod recursive on files on dlublink Linux - Newbie 6 03-02-2005 08:45 AM
chmod.....recursive help stateq2 Linux - General 3 03-28-2004 07:28 PM
Messed up recursive with chmod Cyth Linux - General 4 01-03-2003 12:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration