Date arithmetic in Unix shell scripts

前端 未结 14 1523
生来不讨喜
生来不讨喜 2020-11-27 22:29

I need to do date arithmetic in Unix shell scripts that I use to control the execution of third party programs.

I\'m using a function to increment a day and another

14条回答
  •  独厮守ぢ
    2020-11-27 22:50

    This works for me:

    TZ=GMT+6;
    export TZ
    mes=`date --date='2 days ago' '+%m'`
    dia=`date --date='2 days ago' '+%d'`
    anio=`date --date='2 days ago' '+%Y'`
    hora=`date --date='2 days ago' '+%H'`
    

提交回复
热议问题