Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-18-2006
Registered User
 
Join Date: May 2006
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 05-18-2006
...@...
 
Join Date: Feb 2004
Location: NM
Posts: 9,652
Thanks: 164
Thanked 644 Times in 621 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
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 08:38 AM.