How To Find and Copy Certain Type Of Files From One Directory To Another In Linux

6 Responses

  1. Sankar says:

    Maruvaarthai 🙂 A useful post on find command.. Thank you!!

  2. asdf says:

    Isn’t this recursive? Wouldn’t it them copy all *.mp3 files in all sub-directories as well? What if we don’t want that.

    • sk says:

      In that case, use -maxdpeth flag like below. This will copy the files only from the source directory not from its sub-directories.

      $ find -maxdepth 1 -iname ‘*.mp3’ -exec cp {} /home/sk/test2/ \;

  3. Nick says:

    i want to copy the source directory structure also with files in target folder how do i do that?

  4. Bob Vlaggetjes says:

    great man, so easy to use

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.