How to copy file and locate in new folder?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to copy file and locate in new folder?
# 1  
Old 06-06-2007
How to copy file and locate in new folder?

Hi All,

Please advise me how to make a copy of file from a list and store in one particular location?

For example , I have aaa.txt which contains as below, But, those *usg files might be randomly store in different location....
> cat aaa.txt
adc.usg
dfdjkf.usg
ugjfk.usg


And I want those *usg in aaa.txt store to /var/tmp together. Smilie

Regards,
# 2  
Old 06-06-2007
Code:
while read file
do
   cp `find / -name "$file" 2>/dev/null` /var/tmp 
done<aaa.txt

# 3  
Old 06-06-2007
Code:
while read line
do
 l=$l" -name '$line' -o" 
done < "aaa.txt"
cmd="find / -type f ${l%-o} -print0|xargs -i -0 cp {} /var/tmp "
eval "$cmd"

# 4  
Old 06-07-2007
Thanks you..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy specific file (different but same name) as folder name

I have to copy a particular file present in a main folder having part of the file-name present in many sub-folders to a new destination preserving the name of the source "part of the main folder" and previous file-name of the output file: Example: From /005_0/1000/005.xxx ->... (7 Replies)
Discussion started by: wappor
7 Replies

2. Shell Programming and Scripting

Copy one file from a server to a local folder

Hi, Is there a way I can copy a file from a server to a local folder (i.e. My Documents)? can it be done by scp? I tried this but it just rename the file as the folder it has to be transferred at. scp -r name@some_server:/home/user/file.txt 'somehere\home\home_dir' Thanks. (4 Replies)
Discussion started by: erin00
4 Replies

3. Shell Programming and Scripting

Need help in writitng a script to rename file name and copy to other folder

Hi All, My requirement is as follows: A file (say abc) will be having list of the .txt file names. I need to read this abc file line by line and rename the .txt file names inside it and move them to other folder/path. Eg: abc ------- file1.txt file2.txt file3.txt Output (should... (1 Reply)
Discussion started by: pavan.yadalla
1 Replies

4. Programming

how to copy downloaded file into my source file folder (putty/unix)

I need to "Ensure that when you download libchat.a from the VLE you have copied it to the same folder on ius as your source files. You then refer to the library (and the libraries it needs) with: gcc -o outputfile sourcefile.c -L. -lchat -lsocket -lnsl" But I have no idea what this means! (I... (2 Replies)
Discussion started by: fakuse
2 Replies

5. UNIX for Dummies Questions & Answers

copy files grabbing destination folder from file name

Hi all... Below is what I am trying to do: 1. Having the following folder with the files... /source_folder/dodiddone.tar.gz /source_folder/gowentgone.tar.gz /source_folder/gowentgone.log 2. I need to copy and chown files with extension .tar.gz to another folder copy... (1 Reply)
Discussion started by: pedroz
1 Replies

6. UNIX for Dummies Questions & Answers

Copy the latest (last file) in given folder

#!/bin/bash for i in {1..1536..1} do #find /home/test/Desktop/up111/workplace/Malware/$i/logs for a in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do #max=a for b in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do ... (4 Replies)
Discussion started by: upvan111
4 Replies

7. Shell Programming and Scripting

Now that I have found with Locate, how to copy?

Once I have the output of a command, can I use that output without typing it in or resorting to complicated find/sed gibberish? Surely this is a common enough position to be in that Bash would have a facility for it built in? For instance: dotancohen@dcl:~$ locate Yehu... (7 Replies)
Discussion started by: dotancohen
7 Replies

8. Shell Programming and Scripting

Find all text files in folder and then copy to a new folder

Hi all, *I use Uwin and Cygwin emulator. I´m trying to search for all text files in the current folder (C/Files) and its sub folders using find -depth -name "*.txt" The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies

9. UNIX for Advanced & Expert Users

Auto copy for files from folder to folder upon instant writing

Hello all, I'm trying to accomplish that if a file gets written to folder /path/to/a/ it gets automatically copied into /path/to/b/ the moment its get written. I thought of writing a shell script and cron it that every X amount of minutes it copies these files over but this will not help me... (2 Replies)
Discussion started by: Bashar
2 Replies

10. UNIX for Dummies Questions & Answers

Copy the latest file from a folder

Hi, I have a problem. I have some text files in a folder. The names can be like: emp_20080307053015.dat emp_20080306053015.dat emp_20080305053015.dat emp_20080304053015.dat The date format appended is like yyyymmdd and timestamp. What i need is i have to copy the latest file every... (3 Replies)
Discussion started by: Aswarth
3 Replies
Login or Register to Ask a Question