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.)