Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

HOw to find and copy

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-18-2006
aaajohnson aaajohnson is offline
Registered User
 
Join Date: May 2006
Last Activity: 18 May 2006, 12:42 PM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
HOw to find and copy

Hi,

I need to find files in a directory, between dates like 4/15/06 and 5/02/06, and copy them to a different directory. Is there a way to doa find and a copy together?

Thanks,

Neil
Sponsored Links
    #2  
Old Unix and Linux 05-18-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 24 August 2016, 12:30 PM EDT
Location: NM
Posts: 10,801
Thanks: 436
Thanked 955 Times in 886 Posts
You need to work out the -mtime +<days> and -mtime -<days>
The +<days> = older than, -<days> = younger than


Code:
find /path/to/files -mtime -30 -mtime +13 -print | \
while read file
do
     cp  "$file"  /new/path/`basename "$file"`
done

You may want to mess around with just the first line, until it prints the correct files for you.
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find and copy lol100 Shell Programming and Scripting 1 10-12-2010 06:53 AM
Help with find and copy command bbbngowc Shell Programming and Scripting 2 12-16-2009 03:37 PM
Help with Find All/Copy Script jlfx Shell Programming and Scripting 2 08-31-2008 11:48 AM
need to help to find and copy to a file pujars1 UNIX for Dummies Questions & Answers 2 07-12-2007 09:56 AM
Find directories not containing foo, and copy foo to them dkaplowitz Shell Programming and Scripting 6 06-29-2005 08:50 AM



All times are GMT -4. The time now is 05:34 PM.