copy similar files only both at different locations using script.

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting copy similar files only both at different locations using script.
# 1  
Old 11-23-2007
copy similar files only both at different locations using script.


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

[root@server 123]# pwd

[root@server 123]# cat index.txt

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

[root@server123]# cat /root/x

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

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

[root@server 123]# cat index.home

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


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.


Last edited by fed.linuxgossip; 11-23-2007 at 02:18 AM..
# 2  
Old 11-23-2007
Infact this has been resolved....

root@server[/backup/12345]# cat /root/x
cd /backup/12345/

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

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

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


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


# 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


Last edited by fed.linuxgossip; 11-23-2007 at 05:13 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run a script before and after reboot automatically and send output to two locations.

Hello Team . I am working a health check script ( bash) to run on linux server ( RedHat) and requirements are 1. The o/p of script need to be send to two diff files . I am testing with tee command . But I am not successful yet , any recommendations if that is the right approach ? 2. The same... (2 Replies)
Discussion started by: Varja
2 Replies

2. Shell Programming and Scripting

Shell script to delete empty files from specific locations

Hi, I need help in regard to developing a shell script to delete empty files from multiple specific locations. The directory paths will be stored in a text file. So the requirement is to read the text file for one specific path and then remove empty files from that particular path. Looping through... (4 Replies)
Discussion started by: Khan28
4 Replies

3. Shell Programming and Scripting

awk script to perform an action similar to vlookup between two csv files in UNIX

Hi, I am new to awk/unix and am trying to put together an awk script to perform an action similar to vlookup between the two csv files. Here are the contents of the two files: File 1: Date,ParentID,Number,Area,Volume,Dimensions 2014-01-01,ABC,247,83430.33,857.84,8110.76... (9 Replies)
Discussion started by: Prit Siv
9 Replies

4. Shell Programming and Scripting

Computing the ratio of similar columns in the two files using awk script

Thanks Bartus11 for your help in the following code to compare the two files "t1" and "t2". awk 'NR==FNR{a=1;next}$2 in a{print $2}' t1 t2 First can anyone explain that what is the purpose of assigning a =1? Second, the current script is printing out the matched columns between the... (4 Replies)
Discussion started by: coder83
4 Replies

5. Shell Programming and Scripting

Script to move files with similar names to folder

I have in directory /media/AUDIO/WAVE many .mp3 files with names like: my filename_01of02.mp3 my filename_02of02.mp3 Your File_01of06.mp3 Your File_02of06.mp3 etc.... In the same directory, /media/AUDIO/WAVE, I have many folders with names like 9780743579490 9780743579491 etc.. Inside... (7 Replies)
Discussion started by: glev2005
7 Replies

6. UNIX for Dummies Questions & Answers

Copying files from unix servers to other locations e.g. C directory

Hi, I am just wondering is it possible to move or copy a file from a UNIX server to a different location e.g. the C drive on a computer? I have used the cp command to move files to different locations on unix servers but it would be handy to move a file to my C drive. I am currently... (3 Replies)
Discussion started by: crunchie
3 Replies

7. UNIX for Dummies Questions & Answers

running script in multiple locations

Hey guys I have written a bash script that compares two directories and displays the files that are different in the directories. Now my problem is the script only runs in my home directory. What do I have to do so it will run in other directories. Thanks if anyone can help. Duplicate post.... (0 Replies)
Discussion started by: Joey12
0 Replies

8. Shell Programming and Scripting

Need script to rename the files in different locations

Hi everybody, I need a script for below issue: I have totally 15 different locations like */COUNTRY/in. Only COUNTRy is the variable which changes for 15 countries. For each location(one per country), there will be four files like abc_def_ddmmyyyy.txt, where ddmmyyyy is the old date. ... (1 Reply)
Discussion started by: rjanardhan83
1 Replies

9. Shell Programming and Scripting

Untar files from different locations

Hi all, My tar file exists in directory: /usr/users/rovolis/test1/archive.tar Now from directory: /usr/users/rovolis/ i run the following command tar xvzf /usr/users/rovolis/test1/archive.tar The problem is that the extraction of files is not done Any idea why? Thank you (1 Reply)
Discussion started by: chriss_58
1 Replies

10. UNIX for Advanced & Expert Users

copy files from one location to similar location

I need help in forming a script to copy files from one location which has a sub directory structure to another location with similar sub directory structure, say location 1, /home/rick/tmp_files/1-12/00-25/ here 1-12 are the number of sub directories under tmp_files and 00-25 are sub... (1 Reply)
Discussion started by: pharos467
1 Replies
Login or Register to Ask a Question