linux - n days ago from a given date on command line -


for example, given date '2016-12-31', n 2, expected output '2016-12-29'.

survey date command , n days ago current date easy:
date -d "2 days ago" +%y-%m-%d

just mention date want extract 2 days from:

$ date -d "2016-12-31 2 days ago" +%y-%m-%d 2016-12-29 

or bit better grammatically-wise:

$ date -d "2016-12-31 -2 days" +%y-%m-%d 2016-12-29 

Comments

Popular posts from this blog

c++ - CPP, 'X' button listener -

Get Max value from table in hibernate -

php - Alamofire request parameters empty -