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

后端 未结 17 2145
臣服心动
臣服心动 2020-11-30 17:54

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

17条回答
  •  孤城傲影
    2020-11-30 18:19

    Not very sexy but might do the job:

    perl -e 'my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time - 86400);$year += 1900; $mon+= 1; printf ("YESTERDAY: %04d%02d%02d \n", $year, $mon, $mday)'
    

    Formated from "martin clayton" answer.

提交回复
热议问题