Great Circle Associates Majordomo-Workers
(October 1996)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: Chown and find
From: Jim Jagielski <jim @ jaguNET . com>
Date: Wed, 30 Oct 1996 11:48:57 -0500 (EST)
To: bill @ biome . bio . dfo . ca (Bill Silvert)
Cc: majordomo-workers @ GreatCircle . COM
In-reply-to: <199610301604.MAA27002@biome.bio.dfo.ca> from "Bill Silvert" at Oct 30, 96 12:04:07 pm
Reply-to: jim @ jaguNET . com (Jim Jagielski)

Bill Silvert wrote:
> 
> Jerry Peek writes:
> 
> >>>find . -exec chown $USER {} \;
> >>>find . -exec chgrp $GROUP {} \;
> >
> >This is a good substitute for chown -R, I think.  But if the chown
> >fails on some pathname, the chgrp will run, anyway, and might fail
> >too.  If you write the find another way, a failed chown (with a nonzero
> >status) will prevent the chgrp from running on that particular
> >pathname... it also avoids descending the tree twice:
> >
> >      find . -exec chown $USER {} \; -exec $GROUP {} \;
> >
> >There's an implied "-and" between the first and second -exec's.
> >"find" does left-to-right short-circuit evaluation on the expression;
> >and it will quit if it can tell that the expression will be false.
> 
> An alternative would be to create a file called mjchown as part of the
> installation process, so that we could have
> 
> find $MJ_HOME -exec $MJ_HOME/mjchown $USER $GROUP {} \;
> 
> and write mjchown to be as general and bulletproof as desired, using
> exit codes and so on. I'm not sure about the exit codes, but maybe
> 
> #/bin/sh
> if ( chown $1 $3 )
> then chgrp $2 $3
> fi
> 

I had suggested:
    #!/bin/sh
    #
    # Emulate the user:group and user.group 'chown'
    #  for max portability, assume V7 shell, sed and awk
    #			jmj
    #
    Param=`echo $1 | sed 's/[\.:]/ /'`
    shift
    User=`echo $Param | awk '{ print $1 }'`
    Group=`echo $Param | awk '{ print $2 }'`
    if [ "x$Group" = "x" ]; then
	:
    else
	chgrp $Group "$@"
    fi
    chown $User "$@"

B
-- 
#include <std/disclaimer>
=========================
     Jim Jagielski  << jim@jaguNET.com >>   |   "Not the craw... the CRAW!"


References:
Indexed By Date Previous: Re: Chown
From: "Mark D. Baushke" <mdb@cisco.com>
Next: Re: Majordomo CVS source tree
From: "Lazlo Nibble" <lazlo@swcp.com>
Indexed By Thread Previous: Re: Chown and find
From: bill@biome.bio.dfo.ca (Bill Silvert)
Next: Re: List statistics?
From: Dave Wolfe <dwolfe@risc.sps.mot.com>

Google
 
Search Internet Search www.greatcircle.com