Automate user permission setup

I had a bunch of home directories that I just created.  So now I wanted to set the permissions for each home directory quickly and easily, so it only made sense to automate the process.  The echo commands are not necessary but very helpful when debugging a issue.  This example assumes that you the server is connected to a NIS directory server.

Please note that you can not use UID or GIUD as variables because they are reserved variables.

#!/bin/bash

USERS=\`ls  $PWD|grep -v set_permissions\`

for I in $USERS
do
UIDNUM=\`ypcat passwd|grep $I  |cut -d: -f 3\`
GUIDNUM=\`ypcat passwd|grep $I  |cut -d: -f 4\`
chown -R $UIDNUM:$GUIDNUM $I
echo $I  $UIDNUM $GUIDNUM

done