Louis I. answered 05/25/20
Computer Science Instructor/Tutor: Real World and Academia Experienced
Well, there's no straightforward way to do what you're describing using "cp" ....
That is for example,
copy "dir1/dir2/file.txt" to /tmp/ , and expect "/tmp/dir1/dir2/file.txt" to be created.
I can however think of another way to do it though using the cpio command.
For example:
$ find . -name "file.txt" | cpio -pmdv /tmp/
/tmp/./dir1/dir2/file.txt <<< OUTPUT GENERATED BY CPIO
317 blocks <<< OUTPUT GENERATED BY CPIO
That works ....