Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

509
Views
How to search (using find command) for directories and copy all the files and directory itself to another directory in linux?

How to search (using find command) for directories and copy all the files and directory itself to another directory in linux? Here is what I have so far:

find -type d -name "*.ABC" -exec {} /Desktop/NewFile \;

I get this as output:

find: './GAE/.ABC: PERMISSION DENIED

Please Help, Thanks!

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Your error here above has nothing to do with file read permission. You're trying to execute the directories you find! Avoid running commands as root or sudo unless: (1) you really need it and (2) you really know what you're doing. Quite often people asking for root or sudo privileges are exactly the ones should not have it.

That said... there are several ways to copy a directory tree under *nix. This is just one possible approach:

$ find <start> -type d -name \*.ABC -exec cp -av {} <target> \;

Where:

  • <start> is a directory name. It's used to tell find where to start its search (for example /usr/local or $HOME)
  • <target> is another directory name to define the final destination of your copied directories

UPDATE

In case you want to search for multiple paths...

$ find <start> -type d \( -name \*.ABC -o -name \*.DEF \) -exec cp -av {} <target> \;
over 4 years ago · Santiago Trujillo Report

0

This should work:

find ./source_dir -name \*.png -print0 | xargs -0 cp -t path/to/destination

For more info, you can look up here.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!