Find and copy these files to particular directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find and copy these files to particular directory
# 1  
Old 11-02-2012
Find and copy these files to particular directory

RedHat Enterprise Linux 5.4

I have some files with the extension
Code:
.cdp

in several directories in various mountpoints(filesystems) . I would like to find and copy all these files into a single directory
Code:
/u03/diagnore/data

.

How can I do this ?
# 2  
Old 11-02-2012
Try

Code:
find /source_path/ -name '*.cdp' -exec cp {} /Destination_path/ \;

This User Gave Thanks to pamu For This Post:
# 3  
Old 11-02-2012
Thank you Pamu. What is the significance of curly braces
{}in this command and why is it placed between cp and the target directory ?
# 4  
Old 11-02-2012
Code:
find ... | pax -rw destination

If filename collisions are possible, with pax you can use -k to always keep the existing file, or -u to update (overwrite when the existing destination file is older).

If you need a fancier way to deal with collisions, then you need to provide more info.

Regards,
Alister

---------- Post updated at 10:05 AM ---------- Previous update was at 10:04 AM ----------

Quote:
Originally Posted by kraljic
Thank you Pamu. What is the significance of curly braces
{}in this command and why is it placed between cp and the target directory ?
Type man find at your prompt and read the section which discusses -exec.

Regards,
Alister
This User Gave Thanks to alister For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find most recent file and copy to another directory.

Very new to shell scripting. Not sure if my title is correct but I will try and explain. Directory has 100+ files with this format, " ABCD_ABC_Abc_AB0126.abc ". When a new file gets created, the 16-19 characters in the file name gets incremented by 1. Ex...todays most recent file is... (14 Replies)
Discussion started by: askvip
14 Replies

2. Shell Programming and Scripting

Copy the files in directory and sub folders as it is to another directory.

How to copy files from one directory to another directory with the subfolders copied. If i have folder1/sub1/sub2/* it needs to copy files to folder2/sub1/sub2/*. I do not want to create sub folders in folder2. Can copy command create them automatically? I tried cp -a and cp -R but did... (4 Replies)
Discussion started by: santosh2626
4 Replies

3. Red Hat

Unable to copy files due to many files in directory

I have directory that has some billion file inside , i tried copy some files for specific date but it's always did not respond for long time and did not give any result.. i tried everything with find command and also with xargs.. even this command find . -mtime -2 -print | xargs ls -d did not... (2 Replies)
Discussion started by: before4
2 Replies

4. UNIX for Dummies Questions & Answers

Copy files into another directory

I have a folder will a lot of documents (pdf, xls, doc etc.) which users have uploaded but only 20% of them are currently linking from my html files. So my goal is to copy only the files which are linked in my html files from my Document directory into another directory. Eg: My documents exist... (5 Replies)
Discussion started by: ankitha
5 Replies

5. UNIX for Dummies Questions & Answers

How to find and copy files from one directory to another

Ok i have three directories Destination - /u/dir1 (has subdirectories dir2 which also has subdirectory dir3) Source1 - /u/test/files/dir1/dir2/dir3 Source2 - /u/out/images/dir1/dir2/dir3 What i would like to do is copy everything from Source1 and Source2 into the Destination directory.... (3 Replies)
Discussion started by: ziggy25
3 Replies

6. Shell Programming and Scripting

find and copy file to another directory..

Hi Everybody, i want a samll help to write a script. i had source location with :/user/bin (bin contains subdirectories with like names emails etc and had several files in each subdirectory) and target location with :/usr/scripts (having same subdirectories names and had some files)... (1 Reply)
Discussion started by: Reddy482
1 Replies

7. Shell Programming and Scripting

find list of files from a list and copy to a directory

I will be very grateful if someone can help me with bash shell script that does the following: I have a list of filenames: A01_155716 A05_155780 A07_155812 A09_155844 A11_155876 that are kept in different sub directories within my current directory. I want to find these files and copy... (3 Replies)
Discussion started by: manishabh
3 Replies

8. UNIX for Dummies Questions & Answers

Find & Copy Selected files to another Directory

I am wanting to find files within a directory that are over a certain number of days old and copy them to another directory. And unfortunately not having much luck.......is someone able to help. Would also like to add that there are literally thousands of files that I am wanting to copy in one... (3 Replies)
Discussion started by: hellfyre
3 Replies

9. Shell Programming and Scripting

shell script to find and copy the files creted in the year 2006 to another directory

Hi All, I am new to UNIX. I will be thankful if some one helps me. I have to write a shell script for one of the requirement. I have files created from Jan 2006 to March 2008. My requirement is to write a script in such a way that 1) To find and copy(not Moving) the files created in the... (2 Replies)
Discussion started by: manas6
2 Replies

10. Shell Programming and Scripting

find files and copy into a directory

hi all, can u please help me in finding all ksh file in directory and including all subdirectories and then copy those files into another directory. thanks in advance -bali (4 Replies)
Discussion started by: balireddy_77
4 Replies
Login or Register to Ask a Question