ksh to copy multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh to copy multiple files
# 1  
Old 08-31-2010
ksh to copy multiple files

Guys,

I've got a list of about 200 files I need to copy from /tmp to /data. I can't use wildcards because the filenames are all very different.

What I want to do is cut and paste them into a file and read that as the input to a copy command (line by line). I tried using find and -exec combinations but can't get it to work. Is there a simple way to do:

cp &filename /data

but reading the data from a file containing

filename1
filename2

etc

Any help much appreciated
# 2  
Old 08-31-2010
Hi.

Try with xargs:

Code:
$ cat filelist
file1
file2
file3

$ xargs -n1 -I{} < filelist cp /tmp/{} /data

$ ls /data
file1 file2 file3

# 3  
Old 08-31-2010
A find would look like
Code:
find /tmp -f -name "whatever*" -exec cp -p {} /data \;

For feeding a list:
Code:
while read "LINE"; do
     cp -p "$LINE" /data
done < filelist

# 4  
Old 09-01-2010
Code:
cd /tmp

cat filelist  |xargs -i cp {} /data/

# 5  
Old 09-04-2010
Thanks guys got it working..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Copy data at specified location from multiple files

Hello everyone, Im super new to coding but increasingly in need of it at work. Im have task stacked because of this problems, that I cannot figure out how to solve looking on the internet after trying many many things that looked similar to me. I have multiple data files of the form (see below).... (2 Replies)
Discussion started by: Xfiles_fan
2 Replies

2. Shell Programming and Scripting

Use find with cp and sed in ksh to copy files to a slightly different location

Hello there wonderful people, I am running on Solaris 10 and with the following ksh version: strings /bin/ksh | grep Version | tail -2 @(#)Version M-11/16/88i Suppose I want to copy files that end in _v2 from underneath /dir1/dir2/save directory to /dir1/dir2. Basically, what I’m... (12 Replies)
Discussion started by: ejianu
12 Replies

3. UNIX for Dummies Questions & Answers

UNIX ksh Copy Files Script

I need a UNIX ksh script that counts the number of files in directory, if the files exceed 20 files, then email results. I want the script to run every hour.. I don't have access to cron.. I'm some what new to UNIX. Windows guy all my career.. this is what I have so far.. #!/bin/ksh # count.sh ... (5 Replies)
Discussion started by: PerlHaven2k
5 Replies

4. Shell Programming and Scripting

Copy files matching multiple conditions

Hello How do i copy files matching multiple conditions. Requirement is to search files starting with name abc* and def* and created on a particular date or date range given by the user and copy it to the destination folder. i tried with different commands. below one will give the list ,... (5 Replies)
Discussion started by: NarayanaPrakash
5 Replies

5. UNIX for Dummies Questions & Answers

copy multiple files

Hi, I am facing this problem, however i am not finding any solution. Kindly help I have the list of files to be search , i need to search for those files and copy the files to a folder. Really its urgent. MG_0281.JPG Tdfa_0077.JPG The%20SirehSet%20Geduing%20KpgGlam%20.jpg... (4 Replies)
Discussion started by: umapearl
4 Replies

6. UNIX for Dummies Questions & Answers

Copy multiple files with space to folder

Please help , I am in an urgent need, Please help nawk '{for(i=1;i<=NF;i++){printf("%s\n",$i)}}' filename | sed 's/.*com//' | nawk '/pdf/ {printf("F:%s\n",$0)}' | while read line; do mv $line /images/; done the above script works for without spaces but,My path is also having some space... (3 Replies)
Discussion started by: umapearl
3 Replies

7. UNIX for Dummies Questions & Answers

Zip multiple files and copy to help

Hi All, I have a set of large files ~ 500_900Mb I have generated and I'd like to quickly zip and copy them to a new folder elsewhere ... Can anyone suggest a quicky ?? Cheers :) (3 Replies)
Discussion started by: pawannoel
3 Replies

8. UNIX for Dummies Questions & Answers

Copy multiple files

Hi i have 1000 files is a directory, which are serially numbered (file1,file2,file3...). I would like to copy every 200 files to different directories. many thanks in advance. (6 Replies)
Discussion started by: saint2006
6 Replies

9. UNIX for Dummies Questions & Answers

Copy files in Multiple Threads

Hello all, I have a directory of files of varying sizes. I want to copy all these files in n number of threads to another directory such that each copy set is more or less the same size. Example : Say /mydirA It has around say 23 files of various sizes. Number of copy... (0 Replies)
Discussion started by: samoo
0 Replies

10. UNIX for Dummies Questions & Answers

copy multiple files in different directories

I have a report file that is generated every day by a scheduled process. Each day the file is written to a directory named .../blah_blah/Y07/MM-DD-YY/reportmmddyy.tab I want to copy all of this reports to a separate directory without having to do it one by one. However, if I try cp... (3 Replies)
Discussion started by: ken2834
3 Replies
Login or Register to Ask a Question