[X-Unix] Recursive one-line chmod
Rod Buchanan
lists at sofstats.com
Wed Sep 21 11:34:40 PDT 2005
On 9/21/05 11:09 AM, "Phillip Burk" <philburk at mac.com> wrote:
> Alright, I'm trying to use ARD to issue a one-line command that will
> step through all the directories in /Users and assign recursive
> proper ownership. I don't care if it errors on the Shared folder, I
> have a login hook to blast that to 777. I have no clue as to the
> proper syntax of the thing although if I were using a script to do
> this I imagine it would use a foreach command to parse the usernames
> from the individual directories themselves and then assign ownership
> based on that username.
>
> Kinda like this:
>
> Foreach directory in /Users
> assign name to $username
> if $username=="Shared" then next
> endif
> chown -R $username:admin /Users/$username
This _should_ do what you want. It echos the commands to the screen instead
of running them:
for d in /Users/*
do
u=`basename $d`
if [ "$u" != "Shared" ]
then
echo "chown -R $u:admin $d"
fi
done
Here it is all on one line:
for d in /Users/*; do u=`basename $d`; if [ "$u" != "Shared" ]; then echo
"chown -R $u:admin $d"; fi; done
To "make it so" change
echo "chown -R $u:admin $d"
to
chown -R $u:admin $d
No warranty expressed or implied. Your mileage may vary. Yada yada yada...
:)
--
Rod
Claiming that the Macintosh is inferior to Windows because most people
use Windows, is like saying that all other restaurants serve food that is
inferior to McDonalds'.
More information about the X-Unix
mailing list