How can i make the date command output yesterday's date, current date and the date 4 days ago, in the following format:
2012-10-03
code:
date +% ????
How can i make the date command output yesterday's date, current date and the date 4 days ago, in the following format:
2012-10-03
code:
date +% ????
Try like..
date -d yesterday +%Y%m%d
Try searching
http://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html
With GNU date:
Current date: date +%Y-%m-%d
Yesterday's date: date -d "-1 day" +%Y-%m-%d
4 days ago: date -d "-4 days" +%Y-%m-%d
You can start by reading man date