Path: utzoo!attcan!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.questions Subject: Re: Doing more than one thing at once with find(1) Message-ID: <1990Mar23.141131.8593@virtech.uucp> Date: 23 Mar 90 14:11:31 GMT References: <2578@rodan.acs.syr.edu> Reply-To: cpcahil@virtech.UUCP (Conor P. Cahill) Organization: Virtual Technologies Inc., Sterling VA Lines: 42 In article <2578@rodan.acs.syr.edu> jdpeek@rodan.acs.syr.edu (Jerry Peek) writes: > $ find . \( -type f -exec chmod 600 {} \; \) -o \ > \( -type d -exec chmod 700 {} \; \) > >Even though I've found this, and it seems to work, I still don't >completely understand it. It's sort of like trying to program the >Bourne shell just by reading the sh(1) man page. :-) [:-( ?] The reson for this working the way it does is that there is an implied AND between each pair of operators. This AND acts the same was as the && in C (it is a short circut operator, if the first part is not true, the second part is not examined/executed). In older finds you had to do something like: $ find . \( -type f -a -exec chmod 600 {} \; \) -o \ \( -type d -a -exec chmod 700 {} \; \) Note the -a for specifying the and. Now that we are done with find, I guess I'll comment on your mechanism for changing the mode of your files. A much faster way would be to do the following: find . -type f -print | xargs chmod 600 find . -type d -print | xargs chmod 700 Or you could do it all at once with: find . -type f -print | xargs chmod u+rw,g-rwx,o-rwx Of course this assumes that 1. you have xargs(1) 2. you already had the search bit on for the user(owner) position of the directory modes. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170