Redirecting list of files to cp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Redirecting list of files to cp
# 1  
Old 01-05-2007
Redirecting list of files to cp

I am trying to take a list of filenames and copy those files from one directory into another. Is there a way I can do a 'more' of the file with the filenames and redirect or pipe the output into a 'cp' command. I am using a bash shell. I apologise in advance for what is probably a very simple question.
# 2  
Old 01-05-2007
Quote:
Originally Posted by markp
I am trying to take a list of filenames and copy those files from one directory into another. Is there a way I can do a 'more' of the file with the filenames and redirect or pipe the output into a 'cp' command. I am using a bash shell. I apologise in advance for what is probably a very simple question.
Is this what you want?
Code:
[wayne@UW-GOODRICHWE ~]$ find script -type f
script/testweb.sh
script/changedate.sh
script/rootchk
script/rkhunt.sh
script/testargs.sh
script/test-curl.sh
script/move-capp.sh
[wayne@UW-GOODRICHWE ~]$ find script -type f >> list
[wayne@UW-GOODRICHWE ~]$ cat list
script/testweb.sh
script/changedate.sh
script/rootchk
script/rkhunt.sh
script/testargs.sh
script/test-curl.sh
script/move-capp.sh
[wayne@UW-GOODRICHWE ~]$ mkdir temp
[wayne@UW-GOODRICHWE ~]$ for i in `cat list`; do cp $i temp; done
[wayne@UW-GOODRICHWE ~]$ ls temp
changedate.sh  rkhunt.sh  testargs.sh   testweb.sh
move-capp.sh   rootchk    test-curl.sh
[wayne@UW-GOODRICHWE ~]$

# 3  
Old 01-05-2007
Thankyou very much

That is exactly what I was after.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirecting the results to different output files

Hi All, I am trying a shell script and need your help on taking the results to different output files. I have tried the below code: nawk ' {CNF = (length()-10)/7 printf "%9s", substr ($0, 1, 9) for (i=0; i<=CNF; i++) T = substr ($0, 10+i*7, 7) TMP = 100 - (T + T + T + T + T + T + T + T... (24 Replies)
Discussion started by: am24
24 Replies

2. Post Here to Contact Site Administrators and Moderators

Redirecting grep output to multiple files

Hi All, I am trying to redirect the grep output to multiple files, can you please help with that. Below is the command im using to match my pattern grep \<proxyType\>$PxyType $DIR/EndureFiles.json > File_Name*.json Note : $DIR and $PxyType is already defined in my script Im able... (0 Replies)
Discussion started by: Deena1984
0 Replies

3. UNIX for Dummies Questions & Answers

Redirecting tmp files of SORT into different directory

Hey Guys, I am facing an annoying scenario, fewer times when I execute the sort command, it throws out on error saying that "No Space on available on /var/tmp/<temp file name>. May be it is set to /var/tmp directory. I was wondering, if I cant redirect the temporary file creation to any other... (3 Replies)
Discussion started by: abhisheksunkari
3 Replies

4. Shell Programming and Scripting

Redirecting to different output files with awk.

Well, it didn't take me long to get stumped again. I assure you that I'm not mentally deficient, just new to scripting. So, here's the gist. I want to redirect output from awk based off of which branch of an if-else statement under which it falls. #!/bin/bash #some variables... (2 Replies)
Discussion started by: mikesimone
2 Replies

5. Shell Programming and Scripting

Printing and redirecting files

Hello, I am curious. If I have a line of code run in bash VAR=" It is a nice shiny day " and I would like to be able to print this with the newlines in tact, is there a way? Are the newlines actually there but stripped by echo $VAR or echo -e $VAR? In Python you can:>>>VAR = """... (4 Replies)
Discussion started by: Narnie
4 Replies

6. Shell Programming and Scripting

Redirecting columns from multiple files

Hi all, I have two years worth of daily files (e.g. 090107.dat) and I'd like to write a BASH script to extract the same 2 columns from each of these files and copy them all to one separate file. Could anyone please point me in the right direction as I'm new to shell scripting? It would... (3 Replies)
Discussion started by: larrymuli
3 Replies

7. Shell Programming and Scripting

Redirecting echo output to 2 flat files

Hello all, I have the following 2 questions.. 1) I would like to capture the output of an echo command to 2 different files at the same time. This does not seem to work. Any ideas? echo ==== started on `date` ==== >> res1.log res2.log 2) Would it be possible to just get the 5th... (2 Replies)
Discussion started by: luft
2 Replies

8. UNIX for Dummies Questions & Answers

awk and redirecting to files

Hello, I have a set of data (comma seperated) that I want to save to multiple files according to one of the fields in the data set. I can easily do this with the following script: BEGIN { FS = OFS = ","} NF {print $0 >> ($2 "" ".csv")} It works perfectly on a set of dummy data I have set... (8 Replies)
Discussion started by: pfft
8 Replies

9. Programming

execl() + redirecting output to text files

Im currently using execl() to run the ls command and redirect the output to a text file. Unfortunately, when I check the text file, no information has been written to it. I am calling execl() with the ls command like this execl( "/bin/ls" , "-al" , '>' , "dirlist.txt" ,(char *) 0 ); ... (5 Replies)
Discussion started by: JamesGoh
5 Replies

10. UNIX for Dummies Questions & Answers

Redirecting output to multiple log files?

If I wanted to redirect output to multiple log files, what would be the best way to do that? echo "Unix is awesome" >>unixgod.log >>unixgod.log (3 Replies)
Discussion started by: darthur
3 Replies
Login or Register to Ask a Question