Find the answer to your Linux question:
Results 1 to 3 of 3
Hey is there a way to make use of the results from the find command? ex. [ root@root files]#find . -name "test*" -mtime -1 ./test1.txt ./text5.txt how do i move ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    27

    Move files from find command

    Hey

    is there a way to make use of the results from the find command?

    ex.
    [ root@root files]#find . -name "test*" -mtime -1
    ./test1.txt
    ./text5.txt

    how do i move the results to other directories? i know can do by bash script, but is there another way to do it?

    thanks in advance

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I suggest you look into the "-exec" option for find. A quick example:
    Code:
    find . -name '*.bak' -exec mv '{}' backup_dir/ \;
    This would move every file found into backup_dir/.
    DISTRO=Arch
    Registered Linux User #388732

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    27
    Quote Originally Posted by Cabhan View Post
    I suggest you look into the "-exec" option for find. A quick example:
    Code:
    find . -name '*.bak' -exec mv '{}' backup_dir/ \;
    This would move every file found into backup_dir/.
    cool.. thanks alot

Posting Permissions

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