Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chaging owners by a scirpt .

Status
Not open for further replies.

vti

Technical User
Feb 26, 2001
189
TR

Hi all,

I got nearly 2000 users on my system and some reason their home_path owners changed as root.I want to change their home_path owners by a script.They has to have their own owners name and datau as group.

I got two output one of them like ;

/usr/users/user1
/usr/users/user2
/usr/users/user3

and other file is like ;

user1
user2
user3

All i want to do is

chown user1:datau /usr/users/user1

I have tried with


for i in `cat userspath|awk ' {print $1}'`
do
for e in `cat owners|awk ' {print $1}'`
do
chown $e:datau $i
read a
done
done

But didn't work as i want.

Thanks for any help.
 
This is really a question for a the UNIX Scripting forum, but it loks like you have one to many loops.

Assuming that the home location never changes (/usr/users/)

try the following

<code>

for user_name in `cat owners|awk ' {print $1}'`; do
chown -R $e:datau /usr/users/$i
done
</code>

cheers

Dave
 
hi ,
But /usr/users has also lots of subfolders and paths are diferent.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top