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

qt - QML MouseArea onWheel event not working properly when inside QML Scrollview -

java - is not an enclosing class / new Intent Cannot Resolve Constructor -

python - Error importing VideoFileClip from moviepy : AttributeError: 'PermissionError' object has no attribute 'message' -