I'm running the following on an nfs file system housed on a NetApp:
sudo find . -type d -name .snapshot -prune -exec chmod g+s \{}
I want to set the sgid bit for all directories from here down. It's
deep so I don't want to do it by manually but this doesn't seem to
work, whereas setting it individually does.
Thanks.
~F
|
|
0
|
|
|
|
Reply
|
Faeandar
|
4/20/2004 7:14:28 PM |
|
On Tue, 20 Apr 2004 19:14:28 GMT, Faeandar <mr_castalot@yahoo.com>
wrote:
>I'm running the following on an nfs file system housed on a NetApp:
>
>sudo find . -type d -name .snapshot -prune -exec chmod g+s \{}
>
>I want to set the sgid bit for all directories from here down. It's
>deep so I don't want to do it by manually but this doesn't seem to
>work, whereas setting it individually does.
>
>Thanks.
>
>~F
Nevermind, found my problem. The command should actually look like:
sudo find . -type d -name .snapshot -prune -o -type d -exec chmod g+s
{} \;
This looks to be working a little better. The "\{}" was actually a
typo. I really was doing "{} \;".
I think the problem was the -o option.
~F
|
|
0
|
|
|
|
Reply
|
Faeandar
|
4/20/2004 8:43:22 PM
|
|
Faeandar wrote:
> Nevermind, found my problem. The command should actually look like:
>
> sudo find . -type d -name .snapshot -prune -o -type d -exec chmod g+s
> {} \;
Actually, given that this is comp.unix.solaris, the command should
actually look like:
sudo find . -type d -name .snapshot -prune -o -type d -exec chmod g+s {} +
Note final character. Faster.
MB
|
|
0
|
|
|
|
Reply
|
Mohun
|
4/21/2004 3:54:43 AM
|
|
On Wed, 21 Apr 2004 03:54:43 GMT, Mohun Biswas <m.biswas@invalid.addr>
wrote:
>Faeandar wrote:
>> Nevermind, found my problem. The command should actually look like:
>>
>> sudo find . -type d -name .snapshot -prune -o -type d -exec chmod g+s
>> {} \;
>
>Actually, given that this is comp.unix.solaris, the command should
>actually look like:
>
>sudo find . -type d -name .snapshot -prune -o -type d -exec chmod g+s {} +
>
>Note final character. Faster.
>
>MB
Ok, now I'm curious. What's the difference? I was reading the man
page from a Solaris 8 box that listed the \;.
Thanks.
~F
|
|
0
|
|
|
|
Reply
|
Faeandar
|
4/21/2004 6:35:26 PM
|
|
Faeandar wrote:
> On Wed, 21 Apr 2004 03:54:43 GMT, Mohun Biswas <m.biswas@invalid.addr>
> wrote:
>>Faeandar wrote:
>>>sudo find . -type d -name .snapshot -prune -o -type d -exec chmod g+s
>>>{} \;
>>sudo find . -type d -name .snapshot -prune -o -type d -exec chmod g+s {} +
>>
>>Note final character. Faster.
> Ok, now I'm curious. What's the difference?
With the "+", it will group things together. So, for example, if you
have three directories A, B, and C, the semicolon variation will do
chmod g+s A
chmod g+s B
chmod g+s C
but the plus-sign variation will do
chmod g+s A B C
If you have a whole lot of directories (or files), find will
still break it up into groups.
The latter is faster because it only invokes chmod one time,
which means fewer processes being created, etc., etc.
The plus-sign syntax for find is a relatively new feature of
Solaris, and the feature doesn't exist on several other versions
of Unix.
- Logan
|
|
0
|
|
|
|
Reply
|
Logan
|
4/21/2004 7:52:03 PM
|
|
Logan Shaw <lshaw-usenet@austin.rr.com> writes:
> Faeandar wrote:
>
>> On Wed, 21 Apr 2004 03:54:43 GMT, Mohun Biswas <m.biswas@invalid.addr>
>> wrote:
>
>>>Faeandar wrote:
>
>>>>sudo find . -type d -name .snapshot -prune -o -type d -exec chmod g+s
>>>>{} \;
>
>>>sudo find . -type d -name .snapshot -prune -o -type d -exec chmod g+s {} +
>>>
>>>Note final character. Faster.
>
>> Ok, now I'm curious. What's the difference?
>
> With the "+", it will group things together. So, for example, if you
> have three directories A, B, and C, the semicolon variation will do
>
> chmod g+s A
> chmod g+s B
> chmod g+s C
>
> but the plus-sign variation will do
>
> chmod g+s A B C
So, is
find . -type d -name .snapshot -prune -o -type d -exec chmod g+s {} +
the same as
find . -type d -name .snapshot -prune -o -type d | xargs chmod g+s
??
Bye, Dragan
--
Dragan Cvetkovic,
To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer
!!! Sender/From address is bogus. Use reply-to one !!!
|
|
0
|
|
|
|
Reply
|
Dragan
|
4/21/2004 7:58:30 PM
|
|
Dragan Cvetkovic wrote:
> So, is
>
> find . -type d -name .snapshot -prune -o -type d -exec chmod g+s {} +
>
> the same as
>
> find . -type d -name .snapshot -prune -o -type d | xargs chmod g+s
>
> ??
It's similar, but not the same. The former doesn't send the filenames
through a pipe, and it is "find" that is the parent of the chmod
processes. Also, the latter will not work properly if the filenames
have spaces in them, because xargs treats both spaces and newlines
as separators in the list of filenames. (I never understood why
xargs doesn't have a switch to treat only newlines as separators.
Then it would at least work for the case of filenames that have
spaces but not newlines, which is a very large percentage of the
cases even though newlines are legal in filenames.)
- Logan
|
|
0
|
|
|
|
Reply
|
Logan
|
4/21/2004 8:17:22 PM
|
|
Logan Shaw <lshaw-usenet@austin.rr.com> writes:
> Dragan Cvetkovic wrote:
>> So, is find . -type d -name .snapshot -prune -o -type d -exec chmod g+s
>> {} +
>> the same as
>> find . -type d -name .snapshot -prune -o -type d | xargs chmod g+s
>> ??
>
> It's similar, but not the same. The former doesn't send the filenames
> through a pipe, and it is "find" that is the parent of the chmod
> processes. Also, the latter will not work properly if the filenames
> have spaces in them, because xargs treats both spaces and newlines
> as separators in the list of filenames. (I never understood why
> xargs doesn't have a switch to treat only newlines as separators.
> Then it would at least work for the case of filenames that have
> spaces but not newlines, which is a very large percentage of the
> cases even though newlines are legal in filenames.)
>
Thanks Logan. I am sure xargs has some switch to deal with file names with
spaces (like -I) but there are too many options and too many different
flavours of it (my man page mentions /usr/bin/xargs and
/usr/xpg6/bin/xargs).
Bye, Dragan
--
Dragan Cvetkovic,
To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer
!!! Sender/From address is bogus. Use reply-to one !!!
|
|
0
|
|
|
|
Reply
|
Dragan
|
4/21/2004 8:30:19 PM
|
|
In article <lmad15hzmh.fsf@privacy.net>,
Dragan Cvetkovic <me@privacy.net> wrote:
> So, is
>
> find . -type d -name .snapshot -prune -o -type d -exec chmod g+s {} +
>
> the same as
>
> find . -type d -name .snapshot -prune -o -type d | xargs chmod g+s
>
> ??
Yes, unless any of the filenames contain whitespace. Find will do the
right thing, xargs will treat them as multiple filenames.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
|
|
0
|
|
|
|
Reply
|
Barry
|
4/21/2004 9:08:13 PM
|
|
In article <lm65bthy5g.fsf@privacy.net>,
Dragan Cvetkovic <me@privacy.net> wrote:
> Thanks Logan. I am sure xargs has some switch to deal with file names with
> spaces (like -I) but there are too many options and too many different
> flavours of it (my man page mentions /usr/bin/xargs and
> /usr/xpg6/bin/xargs).
Standard find and xargs don't have any way to deal with them, but GNU
find and xargs have -print0 annd -0, respectively -- they use a null
byte to delimit filenames rather than whitespace.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
|
|
0
|
|
|
|
Reply
|
Barry
|
4/21/2004 9:09:25 PM
|
|
Logan Shaw wrote:
> The plus-sign syntax for find is a relatively new feature of
> Solaris
Actually it's quite an *old* feature of Solaris - Casper Dik said right
here in this NG last year that it's been present since Solaris 2.0. They
just forgot to document it for 10 years or so.
> and the feature doesn't exist on several other versions of Unix.
It's in SUSv3 so it's not a Solaris-only feature per se. Of course older
versions of non-Solaris platforms might not have it yet.
MB
|
|
0
|
|
|
|
Reply
|
Mohun
|
4/21/2004 11:38:46 PM
|
|
Mohun Biswas wrote:
> Logan Shaw wrote:
>
>> The plus-sign syntax for find is a relatively new feature of
>> Solaris
>
>
> Actually it's quite an *old* feature of Solaris - Casper Dik said right
> here in this NG last year that it's been present since Solaris 2.0. They
> just forgot to document it for 10 years or so.
Wasn't that Casper, me, Thomas or any combination of the three? :-)
It's documented in the Solaris 9 find(1) manpage
-exec command
True if the executed command returns a zero value as
exit status. The end of command must be punctuated by
an escaped semicolon (;). A command argument {} is
replaced by the current path name. If the last argu-
ment to -exec is {} and you specify + rather than the
semicolon (;), the command will be invoked fewer
times, with {} replaced by groups of pathnames.
>
>> and the feature doesn't exist on several other versions of Unix.
>
Not on MacOS 10.3.3 - just tried it.
>
> It's in SUSv3 so it's not a Solaris-only feature per se. Of course older
> versions of non-Solaris platforms might not have it yet.
Hmmm. There's a thought. I wonder if the SVR3 on my ancient AT&T
3B2/500 supports it... Must blow the dust off the thing and switch it on!
--
Tony
|
|
0
|
|
|
|
Reply
|
Tony
|
4/22/2004 12:02:57 PM
|
|
Tony Walton <tony.walton@s_u_n.com> writes:
> Mohun Biswas wrote:
>> Logan Shaw wrote:
>>
>>> The plus-sign syntax for find is a relatively new feature of
>>> Solaris
>> Actually it's quite an *old* feature of Solaris - Casper Dik said right
>> here in this NG last year that it's been present since Solaris 2.0. They
>> just forgot to document it for 10 years or so.
>
> Wasn't that Casper, me, Thomas or any combination of the three? :-)
>
> It's documented in the Solaris 9 find(1) manpage
>
> -exec command
> True if the executed command returns a zero value as
> exit status. The end of command must be punctuated by
> an escaped semicolon (;). A command argument {} is
> replaced by the current path name. If the last argu-
> ment to -exec is {} and you specify + rather than the
> semicolon (;), the command will be invoked fewer
> times, with {} replaced by groups of pathnames.
>
Tony, this text needs impovements. You can't say "The end of command must
be punctuated by ;" and then say "if the end is {} + then ...".
Or you can, for a rather specific definition of "must" ...
Bye, Dragan
--
Dragan Cvetkovic,
To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer
!!! Sender/From address is bogus. Use reply-to one !!!
|
|
0
|
|
|
|
Reply
|
Dragan
|
4/22/2004 1:46:56 PM
|
|
Tony Walton <tony.walton@s_u_n.com> writes:
>> Logan Shaw wrote:
>>> The plus-sign syntax for find is a relatively new feature of
>>> Solaris
> I wonder if the SVR3 on my ancient AT&T 3B2/500 supports it...
Possibly not; see David Korn's posting about when he added it:
http://opengroup.org/austin/mailarchives/austin-group-l/msg03065.html
Markus
|
|
0
|
|
|
|
Reply
|
mgyger
|
4/22/2004 2:34:53 PM
|
|
In article <4087B471.7060808@s_u_n.com>,
Tony Walton <tony.walton@s_u_n.com> wrote:
>Mohun Biswas wrote:
>> Logan Shaw wrote:
>>
>>> The plus-sign syntax for find is a relatively new feature of
>>> Solaris
>>
>>
>> Actually it's quite an *old* feature of Solaris - Casper Dik said right
>> here in this NG last year that it's been present since Solaris 2.0. They
>> just forgot to document it for 10 years or so.
>
>Wasn't that Casper, me, Thomas or any combination of the three? :-)
>
>It's documented in the Solaris 9 find(1) manpage
>
> -exec command
> True if the executed command returns a zero value as
> exit status. The end of command must be punctuated by
> an escaped semicolon (;). A command argument {} is
> replaced by the current path name. If the last argu-
> ment to -exec is {} and you specify + rather than the
> semicolon (;), the command will be invoked fewer
> times, with {} replaced by groups of pathnames.
>
And it is a feature found in POSIX.1-2001, so every recent OS should
support it!
--
EMail:joerg@schily.isdn.cs.tu-berlin.de (home) J�rg Schilling D-13353 Berlin
js@cs.tu-berlin.de (uni) If you don't have iso-8859-1
schilling@fokus.fraunhofer.de (work) chars I am J"org Schilling
URL: http://www.fokus.fraunhofer.de/usr/schilling ftp://ftp.berlios.de/pub/schily
|
|
0
|
|
|
|
Reply
|
js
|
4/22/2004 10:37:40 PM
|
|
In article <c69hfk$ek4$1@news.cs.tu-berlin.de>,
Joerg Schilling <js@cs.tu-berlin.de> wrote:
>In article <4087B471.7060808@s_u_n.com>,
>Tony Walton <tony.walton@s_u_n.com> wrote:
[...]
>>It's documented in the Solaris 9 find(1) manpage
>>
>> -exec command
>> True if the executed command returns a zero value as
>> exit status. The end of command must be punctuated by
>> an escaped semicolon (;). A command argument {} is
>> replaced by the current path name. If the last argu-
>> ment to -exec is {} and you specify + rather than the
>> semicolon (;), the command will be invoked fewer
>> times, with {} replaced by groups of pathnames.
>>
>
>And it is a feature found in POSIX.1-2001, so every recent OS should
>support it!
Of course, it's a pretty grubby spec, breaking commands that could
have quite reasonably wanted a single + as an genuine argument. It
would have been better to have had a -execxargs (say) replacing the
-exec verb.
Grubby, but admittedly useful.
Chris Thompson
Email: cet1 [at] cam.ac.uk
|
|
0
|
|
|
|
Reply
|
cet1
|
4/24/2004 11:09:47 PM
|
|
In article <c6es3r$pi0$1@pegasus.csx.cam.ac.uk>,
cet1@cus.cam.ac.uk (Chris Thompson) wrote:
> In article <c69hfk$ek4$1@news.cs.tu-berlin.de>,
> Joerg Schilling <js@cs.tu-berlin.de> wrote:
> >In article <4087B471.7060808@s_u_n.com>,
> >Tony Walton <tony.walton@s_u_n.com> wrote:
> [...]
> >>It's documented in the Solaris 9 find(1) manpage
> >>
> >> -exec command
> >> True if the executed command returns a zero value as
> >> exit status. The end of command must be punctuated by
> >> an escaped semicolon (;). A command argument {} is
> >> replaced by the current path name. If the last argu-
> >> ment to -exec is {} and you specify + rather than the
> >> semicolon (;), the command will be invoked fewer
> >> times, with {} replaced by groups of pathnames.
> >>
> >
> >And it is a feature found in POSIX.1-2001, so every recent OS should
> >support it!
>
> Of course, it's a pretty grubby spec, breaking commands that could
> have quite reasonably wanted a single + as an genuine argument. It
> would have been better to have had a -execxargs (say) replacing the
> -exec verb.
>
> Grubby, but admittedly useful.
POSIX didn't invent it, they just documented the feature that has been
around for years, and apparently hasn't caused havoc to ensue.
Just how many commands are there that take a filename argument followed
by a lone "+"? Yes, it's a theoretical possibility, but in practice
it's not a serious problem.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
|
|
0
|
|
|
|
Reply
|
Barry
|
4/25/2004 2:07:40 AM
|
|
|
16 Replies
273 Views
(page loaded in 0.738 seconds)
Similiar Articles: chmod() Not Owner problem - comp.unix.solarisdtpad and file permissions - comp.unix.solaris 'ttsession -c' does not fix the problem either. - It happens on only one machine; the other ... find and chmod - comp.unix ... chmod and file timestamp - comp.unix.solarisMaybe this is a silly question, and I sort of feel I should know the answer, but... why doesn't chmod in solaris change the time stamp of a file wh... dtpad and file permissions - comp.unix.solarisI have a Solaris 8 machine where, if you load a file into dtpad and save the file, dtpad will change the file permissions (based on the current umask)... Solaris 8: Cannot rm, chmod, chown, or do anything as Root - comp ...Solaris 8: Cannot rm, chmod, chown, or do anything as Root - comp ..... that are Read-only or NFS mounted ... booting it up single-user from CD/net/whatever and fsck all ... Finding and copying the last modified file in a directory - comp ...find and chmod - comp.unix.solaris Finding and copying the last modified file in a directory - comp ... I am hoping to be able to find the last modified file in a ... Finding if read/write/execute permissions - comp.unix.solaris ...All, In bourne shell, I would like to find out if a user has read/write/execute ... solaris ... ls with octal permissions: single line solution - comp.unix ... chmod ... find command to skip directory - comp.unix.adminbash timestamp command history - comp.unix.solaris find command to skip directory - comp.unix.admin find and chmod - comp.unix.solaris get file timestamp - comp.unix ... get umask of existing process? - comp.unix.solarisfind and chmod - comp.unix.solaris... one time, which means fewer processes ... CMASK & UMASK in Solaris 10 - Beginner Question - comp.unix ... Changing CMASK should have ... CMASK & UMASK in Solaris 10 - Beginner Question - comp.unix ...Changing CMASK should have no effect on existing files, only new ones. If you want to change existing files, see: man find and man chmod /:-/ bash timestamp command history - comp.unix.solarisfind command to skip directory - comp.unix.admin find and chmod - comp.unix.solaris get file timestamp - comp.unix.programmer find command to skip ... to remove a nonempty ... NFS solaris 10 "Stopping because all processes in service exited ...find and chmod - comp.unix.solaris The latter is faster because it only invokes chmod one time, which means fewer processes being ... zero value as exit ... exec with start and file names with spaces - comp.lang.tcl ...find and chmod - comp.unix.solaris... running the following on an nfs file system housed on a NetApp: sudo find . -type d -name .snapshot -prune -exec ... has some switch ... begginer: setting the exit status - comp.lang.awkCMASK & UMASK in Solaris 10 - Beginner Question - comp.unix ... begginer: setting the exit status - comp.lang.awk find and chmod - comp.unix.solaris... command returns a ... unable to chmod as root - comp.unix.programmeranyone ever run into this problem? I can chmod as root in other directories, just not this one. # whoami root # chmod 775 /usr/sap/sapstore/back ch... single line command to remove a nonempty folder - comp.unix ...I always do something like: # find . -type f -exec chmod 440 '{}' ';' I see that you use: {} + Is there a difference? -- Dick Hoogendijk -- PGP/GnuPG key: F86289CE ... FIND/CHMOD combined - The UNIX and Linux ForumsI am trying to change permission for all subdirectories and files inside folder1 so this is what i came with after many seraches on the internet. man find and man ... FilePermissions - Community Ubuntu DocumentationUnderstanding and Using File Permissions. In Linux and Unix, everything is a file. Directories are files, files are files and devices are files. 7/24/2012 7:20:03 PM
|