|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I want to create an automated script that runs each day. What I want the script to do is to grep on the previous day's date (yesterday) from a text file and output the results to a file. Date is in the format as shown below:
egrep "\[01\/Nov\/2003" /mydir/myfiles/ > /home/tmp/mytestfile How can I achieve this result? Thanks in advance |
|
#2
|
|||
|
|||
|
perl?
I know using yesterday can turn into a total mess. One idea comes to mind , write your script in perl, invoke date(use Date::Calc qw(:all)) and use add_Delta_days.
You can find Date::Calc using google - search for "perl Date::Calc" The syntax: Add_Delta_Days($year,$month,$day,"#DaysToAdd") in your case #DaysToAdd would by -1. This will return the day before the $year,$month,$day from above in the format year,month,day. You can then use that to grep your directories/files in perl using either the system("command") or back ticks `command`. Good luck................. Last edited by gruntz : February 4th, 2004 at 11:15 AM. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > C Shell gurus, please help!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|