Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

find command

Ravi_65
Occasional Contributor

find command

Can we find some files in a particual dir and copy them to some different folders using a single command (find)?
No limit to learning.
3 REPLIES
Bojan Nemec
Honored Contributor

Re: find command

Hi,

You can use -exec.

$ find . -exec cp {} /newdir/ ';'

Bojan
Josef Forman
Frequent Advisor

Re: find command

Hi!
I think yes, you can use "-exec {}" in find command.
Something like:

find . -name mountain.jpg -exec cp '{}' / \;

PF
Fred Ruffet
Honored Contributor

Re: find command

What are your search criteria for files ? Are they in a single directory or sub-directory ? Do you want to copy directory structure or not ?

In case of all file in all sub-dirs copied in a single dir, it looks like that :

find /search/dir -name "foo*" -exec cp {} /to/dir \;

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)