copy similar files only both at different locations using script.

Hello,

Here is the situation..............

[root@server 123]# pwd
/opt/123

[root@server 123]# cat index.txt
abc-monitor/homedir/public_html/index.php
abc-monitor/homedir/public_html/test/index.php
abc-monitor/homedir/public_html/test1/index.php

[root@server 123]# cp index.txt index.home

[root@server123]# cat /root/x
#!/bin/bash
user="monitor"

replace "cpmove-$user/homedir" "/$user" -- index.home

[root@server 123]# chmod +x /root/x ; /root/x

[root@server 123]# cat index.home
/home/monitor/public_html/index.php
/home/monitor/public_html/test/index.php
/home/monitor/public_html/test1/index.php

Now I want such a script that all files in `cat index.txt` will move to `cat index.home` and replace them.

Example...

mv -f abc-monitor/homedir/public_html/index.php /home/monitor/public_html/index.php
mv -f abc-monitor/homedir/public_html/test/index.php /home/monitor/public_html/test/index.php
mv -f abc-monitor/homedir/public_html/test1/index.php /home/monitor/public_html/test1/index.php

Please advise.

Thanks

Infact this has been resolved....

root@server[/backup/12345]# cat /root/x
#!/bin/bash
cd /backup/12345/
user="user1"

tar -tvzf /backup/cpbackup/weekly/$user.tar.gz | grep index.php |awk {'print $6'} > index.txt

for extract in `cat index.txt`
do
tar -xzf /backup/cpbackup/weekly/$user.tar.gz $extract
done

mv $user/whatchatdir/ /backup/12345/
rm -fr $user
mv whatchatdir $user
rsync -vrplogDtH $user/ /whatchat/$user/
chmod 711 /whatchat/$user ; chown $user.$user /whatchat/$user
chmod 710 /whatchat/$user/public_html ; chown $user.nobody /whatchat/$user/public_html
rm -fr $user
echo " ################ index.php's copie for $user ############"
root@server [/backup/12345]#

===========
But .... who to get user variable from an another file that has the list of users...

exmaple: -- I have a file called user.txt

cat user.txt

user1
user2
user3
user4
user5

Please advise ...

Infact I have a workaround with me now... but it is not the best solution..

first ran the script for user1 by adding user=user1

next

# head /root/z
replace user1 user2 -- /root/x ; /root/x ;
replace user2 user3 -- /root/x ; /root/x ;
replace user3 user4 -- /root/x ; /root/x ;

# chmod + x /root/z ; /root/z

Thanks