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

link|improve this question
feedback

2 Answers

rsync -rlpv --files-from=<(find ...) /user/username/projects /user/newuser
link|improve this answer
feedback

If you can be sure that all of the subdirectories exist, then this is a fun option:

cd /user/username/
find . -name \*.gz | sed 's/\.\(.*\)/.\1 ..\/newuser\1/' | xargs -n2 cp
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.