troubleshooting Question

How to find certain files and copy them with their directories to a directory?

Avatar of meade470
meade470 asked on
Unix OSLinuxShell Scripting
4 Comments2 Solutions133 ViewsLast Modified:
We are trying to find all files in a directory, that contains multiple sub-directories for the file type ".png" and ".jpg". We are using:

find /otrs_attachment_files/2013/10/15/ -type f \( -name "*.png" -o -name "*.jpg" \) -exec cp -ar {} /root/otrs_test_filebackup \;

but it doesn't retain each files' directory.

What's the proper command?
ASKER CERTIFIED SOLUTION
ThomasMcA2

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros