FIXED Re: script to find files owned by particular user and …

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: JT Moree
Date:  
To: Main PLUG discussion list
Old-Topics: script to find files owned by particular user and replace with another uid
Subject: FIXED Re: script to find files owned by particular user and replace with another uid

!!!WARNING!!! this is not tested or debugged. I just wrote it.

ARRRGH. I keep typing chmod instead of chown.

#!/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

chown `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 -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss