Results 1 to 2 of 2

Thread: locate and copy files

Hybrid View

  1. #1
    Join Date
    Jan 2008
    Beans
    6

    locate and copy files

    Hello all,

    I have been trying to do a script that can copy files of a certain type/name to a directory of my choosing.

    The idea is to create a text file that contains for instance
    Penguin
    Dogs*
    lunatic*
    Then I want the script to locate those files in all directories and subdirectories from the directories I run the script and then copy them to the file /animals/

    HAve anyone done a script like this already? I've been trying some using find etc but I think my scripting talents are lacking...

    Thanks ahead!

    Mikael

  2. #2
    Join Date
    Mar 2011
    Beans
    78

    Re: locate and copy files

    Something like this?

    Code:
    while read line; do find directory_to_search -name "$line" -exec cp {} directory_to_copy_to \;; done < file_containing_filenames

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •