The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-23-2007
fed.linuxgossip fed.linuxgossip is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 99
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..
  #2 (permalink)  
Old 11-23-2007
fed.linuxgossip fed.linuxgossip is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 99
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..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0