Automate copying files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automate copying files
# 1  
Old 03-18-2015
Code Automate copying files

Need assistance in automate a process.

directory has list of files that needs to be copied based on the paths listed in another file . Need to automate this process. Your inputs are highly appreciated


Directory that has list of files.
Code:
abc.sh
def.sh
demo.sh
foo.sh
bar.sh

File which has all the paths
Code:
/home/demo/script/abc.sh
/home/demo/fc/scripts/hello.sh
/home/gear/scripts/test.sh
/home/scripts/demo.sh


Last edited by ajayram_arya; 03-18-2015 at 02:53 PM.. Reason: formating
# 2  
Old 03-18-2015
Quote:
Originally Posted by ajayram_arya
Need assistance in automate a process.

directory has list of files that needs to be copied based on the paths listed in another file . Need to automate this process. Your inputs are highly appreciated

Directory has list of files.
Code:
abc.sh
def.sh
demo.sh
foo.sh
bar.sh

File which has all the paths
Code:
/home/demo/script/abc.sh
/home/demo/fc/scripts/hello.sh
/home/gear/scripts/test.sh
/home/scripts/demo.sh


is this wat you are try to do

Code:
for i in *.sh
do
path=`grep $i <pathtofilecontaingthepaths>`
cp $i $path
done

This User Gave Thanks to zozoo For This Post:
# 3  
Old 03-18-2015
Zozoo thank you for nailing down the answer . Really appreciate your quick response.

Quote:
Originally Posted by zozoo
is this wat you are try to do

Code:
for i in *.sh
do
path=`grep $i <pathtofilecontaingthepaths>`
cp $i $path
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automate splitting of files , scp files as each split completes and combine files on target server

i use the split command to split a one terabyte backup file into 10 chunks of 100 GB each. The files are split one after the other. While the files is being split, I will like to scp the files one after the other as soon as the previous one completes, from server A to Server B. Then on server B ,... (2 Replies)
Discussion started by: malaika
2 Replies

2. Shell Programming and Scripting

Copying files

I'm trying to do this exact same thing, so far I have created this to move files i've named my script CP.sh #!/bin/bash cd /root/my-documents/NewDir/ for f in *.doc do cp -v $f root/my-documents/NewDir $f{%.doc} done When i go to run this in the console i type, bin/sh/ CP.sh but it... (7 Replies)
Discussion started by: MKTM_93_SIMP
7 Replies

3. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

4. Shell Programming and Scripting

Copying Files

Hi All, I'm trying to list some files from my log directory and files are like this log.20110302_20.gz log.20110302_21.gz log.20110302_22.gz log.20110302_23.gz log.20110303_00.gz log.20110303_01.gz log.20110303_02.gz ............ log.20110311_22.gz log.20110311_23.gz... (2 Replies)
Discussion started by: thelakbe
2 Replies

5. Shell Programming and Scripting

How to automate sftp in a script to 'get' files.

Hi, I read a couple of forum entries about scripting sftp using the '-b' option, but in my case it still prompts for the password. Does anyone have a sample script for an sftp block to 'get' files from the remote server without prompting for a password? Both the remote and the local servers... (1 Reply)
Discussion started by: ChicagoBlues
1 Replies

6. UNIX for Advanced & Expert Users

copying of files by userB, dir & files owned by userA

I am userB and have a dir /temp1 This dir is owned by me. How do I recursively copy files from another users's dir userA? I need to preserve the original user who created files, original group information, original create date, mod date etc. I tried cp -pr /home/userA/* . ... (2 Replies)
Discussion started by: Hangman2
2 Replies

7. Solaris

Copying Files

Hi, I understand that to copy files across server, the feasible way will be using scp command. Am I right? What if the two servers are not connected to a network? If by using a cross cable to link up both the server, what will be the best (fastest) way to copy files across? scp as well? ... (3 Replies)
Discussion started by: user50210
3 Replies

8. Shell Programming and Scripting

Automate daily FTP files

How to automate FTP files daily with the following constraints 1) Try (every 15 mins or 30 mins) FTP till it reconnects 2) Files that arrive in between 5:30 pm and 2:00 am 3) The sat and sun, mon files are to be FTP on monday. 4) Only the txt files are to be FTP'ed. The following are the... (2 Replies)
Discussion started by: bobbygsk
2 Replies

9. UNIX for Advanced & Expert Users

automate backing up uploaded files

Hi, We are running FTP Server on UNIX (Solaris 9). Users login and upload (also download) files whenever required. Now, we have to automate the process which makes a copy of every file immediately after it gets uploaded to the FTP server (by any user). I've ruled out rsync,mirror,filesync... (2 Replies)
Discussion started by: prvnrk
2 Replies

10. UNIX for Dummies Questions & Answers

Copying files

I like to know the command structure of copying files/directories from a unix box using telnet session to a windows box. (4 Replies)
Discussion started by: alpheusm
4 Replies
Login or Register to Ask a Question