[SLL] how to display previous day's date [was: newest "date" in RHL...]

Phil Mocek pmocek-sll at mocek.org
Fri Jun 1 11:10:29 PDT 2007


On Fri, 1 Jun 2007, William Kreuter wrote:
> My script needs to obtain the previous day's date on each day of
> the month.  Since I don't see an argument to date which would do
> the reverse of "date +%s", please give me some ideas with which
> I could keep my bash script nice and compact.

If you need to find the date one day prior to a particular day,
you could, as Andrew suggested, use:

    date -d '1jun07 -1 day'

If you're simply looking for the day prior to the current day, you
can use:

    date -d yesterday

or:

    date -d '1 day ago'

For more options, try:

    info date

(The Texinfo page for date is much more detailed than the manual
page for it.)

-- 
Phil Mocek



More information about the linux-list mailing list