- To: slug@xxxxxxxxxxx
- Subject: Re: [SLUG] chmod probs.
- From: jam <jam@xxxxxxxxx>
- Date: Sat, 11 Apr 2009 07:57:09 +0800
- User-agent: KMail/1.10.3 (Linux/2.6.27.21-0.1-default; KDE/4.1.3; x86_64; ; )
On Saturday 11 April 2009 00:06:56 slug-request@xxxxxxxxxxx wrote:
[snip]
> > What am I missing?
>
> find(1), which is used to locate a list of files matching a given set of
> criteria, allowing you to do something like this:
>
> chmod -R 644 `find -name '*.jpg'`
>
> (Note the single-quotes around the glob pattern? Without that the shell
> would expand the pattern, which would cause a syntax error for the find
> command, and not do what you want.)
>
> There is a limit to the number of arguments you can pass to chmod,
> though, so it is generally speaking better to structure that like this:
>
> find -name '*.jpg' | xargs chmod -R 644
>
> That falls apart if any of your filenames have spaces in them, though,
> since xargs splits on *any* whitespace; to work around that use:
>
> find -name '*.jpg' -print0 | xargs -0 chmod -R 644
>
> See the manual pages for the fine detail, obviously.
Um sure, but in this context too complicated IMHO
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
which does what he said he wanted to do without fussing about jpgs etc
"I have a bunch of directories with a bunch of files (pictures) in each.
I want to set directories to 775 and files to 664."
James