subtract days from a date in bash

前端 未结 6 1637
梦谈多话
梦谈多话 2020-12-13 23:13

I want to subtract \"number of days\" from a date in bash. I am trying something like this ..

echo $dataset_date #output is 2013-08-07

echo $date_diff #outp         


        
6条回答
  •  自闭症患者
    2020-12-14 00:13

    Here is my solution:

    echo $[$[$(date +%s)-$(date -d "2015-03-03 00:00:00" +%s)]/60/60/24]
    

    It calculates number of days between now and 2015-03-03 00:00:00

提交回复
热议问题