The UNIX and Linux Forums  

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


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
files between any two given dates thanuman UNIX for Dummies Questions & Answers 8 12-05-2007 11:16 PM
Files and dates mastachef UNIX for Dummies Questions & Answers 1 12-03-2007 11:12 AM
Files created in last 24 hours jayaramanit Shell Programming and Scripting 1 09-08-2007 01:34 AM
Files created by particular user Anshu UNIX for Dummies Questions & Answers 2 06-13-2006 05:12 AM
Two Files Created For Every One? Atama UNIX for Dummies Questions & Answers 1 04-12-2002 01:44 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 07-26-2007
Registered User
 

Join Date: Jul 2007
Posts: 12
Copy only files created between two dates

Hi all,

I like to get two date values from command line, and I have to copy all the files created in between that dates in a particular folder to destination folder. The date comparison is little bit consusing me. Please help.

Regards
Sethu.
Reply With Quote
Forum Sponsor
  #2  
Old 07-27-2007
Registered User
 

Join Date: Jul 2007
Posts: 1
Hey,

U can refer this link

http://www.unix.com/tips-and-tutoria...n-in-bash.html

This has some methods for calculating the date difference.

Thanks
Reply With Quote
  #3  
Old 07-27-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Quote:
Originally Posted by r_sethu View Post
Hi all,

I like to get two date values from command line, and I have to copy all the files created in between that dates in a particular folder to destination folder. The date comparison is little bit consusing me. Please help.

Regards
Sethu.
What is the format of the date ? You should look into the utilities date and touch.

You should do something on the following lines.
Code:
#! /bin/sh
#
# Input: 2 parameters <from_date> <new_date>
#
touch -d <from_date> /tmp/temp.file
find /path/to/search -newer /tmp/temp.file -type f 2>/dev/null >/tmp/file.from

touch -d <new_date> /tmp/temp.file
find /path/to/search -newer /tmp/temp.file -type f 2> /dev/null >/tmp/file.new

grep -v -f /tmp/file.new /tmp/file.from > /tmp/file.list
for file in $(< /tmp/file.list)
do
  /bin/cp $file /destination/folder
done

rm -f /tmp/file.list /tmp/file.new /tmp/file.from /tmp/temp.file
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0