Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

touching a file with date in past.

SOLVED
Go to solution
Dave Walley
Frequent Advisor

touching a file with date in past.

Hi.

I need to find all files since a time a number of days ago. I currently use this to create a file dated at midnight

touch -t `eval "date +'%y%m%d0000'"` todayfile

and I then use find using the newer keyword.
What I now need is the ability to create a file dated midnight two days previously.

Thanks in advance.

Dave
why do i do this to myself
4 REPLIES
Fred Ruffet
Honored Contributor
Solution

Re: touching a file with date in past.

Hi !

There may be two solutions for you :
. Install and use GNU date, wich is the same with more options. It may help you with options such as "date --date='2 days ago'".
. Use a script that is often mentioned here. Its name is something like calj or calij. I'm experiencing problems whith searching on HP site, but you may find threads in ITRC dealing with it.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Michael Tully
Honored Contributor

Re: touching a file with date in past.

The tool your after is called 'caljd' by our friend Clay Stephenson. If you use the word 'caljd' in the search engine, there are a pile of examples and in many there is an attachement of the script, which is written in perl.
Anyone for a Mutiny ?
Muthukumar_5
Honored Contributor

Re: touching a file with date in past.

We can do it with scripting easily. Attached script will give the 2 days before information by calculating and exports to dayinfo shell variable. Using crontab execute this model script to change ur dayinfo variable. It will update the dayinfo with 2 days before from now.

Use the touch command as like,

touch -t `echo $dayinfo` todayfile

It will do your requirement.

NOTE: Year is calculated as yy ( 04 ) not as 2004
Easy to suggest when don't know about the problem!
Fred Ruffet
Honored Contributor

Re: touching a file with date in past.

Muthukumar,

What about bissextile years in your script ? (don't know if it's the correct word in english : year with 366 days)

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)