Team,
How do i fetch details of the last day of the month i.e 31st,30th
because we receive daily status report but not for the last days of the month..
because when i do an
echo `date +%Y%m `${yesterday}
it retrieves me 20100631 where as it should have been 20100531..
Hmm interesting!
PS:Please dont treat this as an assignment
Warm regards
Whizkidash
No...
But i have found solution for the same
If i do this..
echo `TZ=TZ+24 date +%Y%m%d`
It works
Thanks mate!
Cheers
Whizkidash
I think your code works only for a few hours of the day.
I agree. Manipulating the TZ variable in this manner can only work properly 24/7 in the GMT timezone.
The original command posted does not work because ${yesterday} is not set and evaluates to blank. The command as posted just executes:
date +%Y%m
If only we knew which Operating System and Shell the O/P has?
Iin general it is usually better to use a 00:01 cron to create a reference file "today" and age the file daily to create "yesterday" and "day-before-yesterday" files. Each file can contain the date in the format required by the reporting process or the reporting process could use the timestamp of the relevant file.