Get the date (a day before current time) in Bash

conandor picture conandor · Nov 10, 2009 · Viewed 274.2k times · Source

How can I print the date which is a day before current time in Bash?

Answer

ghostdog74 picture ghostdog74 · Nov 10, 2009

if you have GNU date and i understood you correctly

$ date +%Y:%m:%d -d "yesterday"
2009:11:09

or

$ date +%Y:%m:%d -d "1 day ago"
2009:11:09