![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Comparing similar columns in two different files | ragavhere | Shell Programming and Scripting | 13 | 04-16-2008 08:53 AM |
| Urgent !!! Shell script to copy files to VSS | devalin | Shell Programming and Scripting | 1 | 08-20-2007 06:16 AM |
| Script that can Copy a Range of files from Tape to Hard disk | msjazzie | Shell Programming and Scripting | 0 | 08-13-2007 03:47 PM |
| script to rename files with current date and copy it. | logic0 | UNIX for Dummies Questions & Answers | 6 | 05-01-2007 05:13 AM |
| copy files without password in script | jwala | Shell Programming and Scripting | 0 | 02-12-2006 01:10 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 Last edited by fed.linuxgossip; 11-23-2007 at 01:18 AM.. |
|
||||
|
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 Last edited by fed.linuxgossip; 11-23-2007 at 04:13 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|