From what I've read: date -d "1 day ago" should be smart enough to know that on the first day of the month, 1 day ago was 30|31 (or 28|29) of LAST month. Also true for January 1 (and knowing it was last month AND last year). I tested like this:
bash-3.2$ date +%j
193
bash-3.2$ date -d "193 day ago "
Sat Dec 31 14:54:22 UTC 2011
Should this hold true? | [reply] [d/l] [select] |
Yes, '1 day ago' affects the full date, not just the day. But you get year, month, and day with separate calls - so if you need to get the day again with '1 day ago', you should also get the month and year again with '1 day ago'.
You could get them with one system call:
($y,$m,$d) = split/\s/,`date "+%Y %M %d"`;
($y,$m,$d) = split/\s/,`date -d "1 day ago" "+%Y %M %d"`;
| [reply] [d/l] |