Daniel Woods wrote on Tue, Sep 24, 2002 at 01:58:42PM -0600 :
> 
> > >   find /var/www -type d -exec chmod g+s {} \;
> > Does it work if the directory name or path contains spaces?  I am unable
> > to test at the moment (short on time).
> Yes.

I tested and verified that it does work.  But I have one comment about
what you posted below:

> # mkdir '/tmp/test with spaces'
> # find /tmp -type d -exec echo {} \;
> .
> ./.font-unix
> ./BACKUP
> ./BACKUP/SQL
> ./kde-dwoods
> ./.ICE-unix
> ./test with spaces

What you have done here does not prove the test.  I get the same results
by doing:
  echo "dir owned by todd"
  echo dir owned by todd

> # rm -rf '/tmp/test with spaces'

See how you had to put quotes around the path?  That's what my awk did.
I had to do that because the following are not identical because the
space is normally an argument delimiter:

  rm -rf "/tmp/test with spaces"
  rm -rf /tmp/test with spaces
  
And after testing, I verified that the find command when it replaces the
{} argument with the value that it is currently processing, it does in
fact quote it, so that answers my question:

[root@fiji ~]# mkdir dir1
[root@fiji ~]# cd dir1
[root@fiji ~/dir1]# mkdir "this is a test"
[root@fiji ~/dir1]# mkdir "this is test 2"
[root@fiji ~/dir1]# mkdir ouch
[root@fiji ~/dir1]# cd ..
[root@fiji ~]# find dir1 -type d -exec chmod g+s {}
find: missing argument to `-exec'
[root@fiji ~]# find dir1 -type d -exec chmod g+s {} \;
[root@fiji ~]# vdir dir1
total 12
drwxr-sr-x    2 root     root         4096 Sep 24 14:51 ouch
drwxr-sr-x    2 root     root         4096 Sep 24 14:51 this\ is\ a\
test
drwxr-sr-x    2 root     root         4096 Sep 24 14:51 this\ is\ test\ 2

Thanks for the command and thanks for making me think about it thanks
for letting me verbalize what was going through my head.

I actually did try to use the find command originally, but I kept
getting that damned "missing argument to -exec" error message.  I am an
idiot sometimes.  I forgot all about escaping the ; at the end. :(

Blue skies...                   Todd
-- 
           MandrakeSoft USA   http://www.mandrakesoft.com
Mandrake: An amalgam of good ideas from RedHat, Debian, and MandrakeSoft.
All in all, IMHO, an unbeatable combination.   --Levi Ramsey on Cooker ML
   Cooker Version mandrake-release-9.0-0.3mdk Kernel 2.4.19-12mdk

Attachment: msg58026/pgp00000.pgp
Description: PGP signature

Reply via email to