Craig White wrote:
> Anybody have a script that finds file say owned by uid=1010 and replace
> owner with uid=1020?
something like
chmod `grep 1020 /etc/passwd | awk -F: '{print $1;}'` \
`find . -uid 1010`
or to make it reusable
!!!WARNING!!! this is not tested or debugged. I just wrote it.
#!/bin/sh
USER1=$1
USER2=$2
MYPATH=$3
usage()
{
echo "Script to change ownership of files from user X to user Y"
echo "$0 <user1> <user2> [path to search]"
echo
}
if [ -z "$USER1" ] ; then echo "Invalid user 1"; usage ; exit 1; fi
if [ -z "$USER2" ] ; then echo "Invalid user 2"; usage ; exit 1; fi
if [ -z "$MYPATH" ] ; then MYPATH="./" ; exit 1; fi
UID1=`grep $USER1 /etc/passwd | awk -F: '{print $3;}' `
UID2=`grep $USER2 /etc/passwd | awk -F: '{print $3;}' `
if [ -z "$UID1" ] ; then echo "Invalid user 1"; usage ; exit 1; fi
if [ -z "$UID2" ] ; then echo "Invalid user 2"; usage ; exit 1; fi
chmod `grep $USER1 /etc/passwd | awk -F: '{print $1;}'` \
`find $MYPATH -uid $UID2`
- --
JT Morée
PC Xperience, Inc.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss