Copy a file from source directory to target base directory and maintain source path

Posted by Citizen Dos on Super User See other posts from Super User or by Citizen Dos
Published on 2010-10-07T01:50:32Z Indexed on 2011/03/11 8:12 UTC
Read the original article Hit count: 291

Filed under:
|
|

Forgive me, I am probably not using the right terms to describe the problem and misunderstanding the most basic usage for a couple of common commands.

I have a simple find statement that is locating files that I want to copy. I want to tack on the -exec cp {} and have cp copy the file from the source directory to a new base directory, but include the full path. For example:

"find . -name *.txt" locates /user/username/projects/source.txt "cp {} [now what?]" copies the file to /user/newuser/projects/source.txt

© Super User or respective owner

Related posts about osx

Related posts about copy