Get today's Date:
[Email protected] ~]# date-d "Now" +%y%m%d
20150819
[Email protected] ~]#
Get Yesterday's date:
[[email protected] ~]# date-d "1 day Ago" +%y%m%d
20150818
[Email protected] ~]# date-d "Yesterday" +%y%m%d
20150818
[Email protected] ~]# date-d "-1 days" +%y%m%d
20150818
[Email protected] ~]#
Get the date of the day before:
[[email protected] ~]# date-d "2 day Ago" +%y%m%d
20150817
[Email protected] ~]# date-d "-2 Days" +%y%m%d
20150817
[Email protected] ~]#
Get the date of the forward day:
[[email protected] ~]# date-d "3 day Ago" +%y%m%d
20150816
[Email protected] ~]# date-d "-3 days" +%y%m%d
20150816
[Email protected] ~]#
Get Tomorrow's Date:
[Email protected] ~]# date-d "Tomorrow" +%y%m%d
20150820
[Email protected] ~]# date-d "Next-day" +%y%m%d
20150820
[Email protected] ~]# date-d "Day" +%y%m%d
20150820
[Email protected] ~]# date-d "+1 days" +%y%m%d
20150820
[Email protected] ~]#
Get the date after two days:
[Email protected] ~]# date-d "2 Day" +%y%m%d
20150821
[Email protected] ~]# date-d "+2 days" +%y%m%d
20150821
[Email protected] ~]#
Get the date after three days:
[Email protected] ~]# date-d "3 Day" +%y%m%d
20150822
[Email protected] ~]# date-d "+3 days" +%y%m%d
20150822
[Email protected] ~]#
Get date after January:
[Email protected] ~]# date-d "Next-month" +%y%m%d
20150919
[Email protected] ~]# date-d "Month" +%y%m%d
20150919
[Email protected] ~]#
Get the date of the second day after January:
[Email protected] ~]# date-d "Month 2 Day" +%y%m%d
20150919
[Email protected] ~]#
Get the date before the month:
[Email protected] ~]# date-d "Last-month" +%y%m%d
20150719
[Email protected] ~]#
Get the date one year ago:
[Email protected] ~]# date-d "Last-year" +%y%m%d
20140819
[Email protected] ~]# date-d "-1 year" +%y%m%d
20140819
[Email protected] ~]#
Get the day before the year before:
[Email protected] ~]# date-d "-1 year-1 days" +%y%m%d
20140818
[Email protected] ~]#
Get the date one year later:
[Email protected] ~]# date-d "Next-year" +%y%m%d
20160819
[Email protected] ~]# date-d "Year" +%y%m%d
20160819
[Email protected] ~]# date-d "+1 Year" +%y%m%d
20160819
[Email protected] ~]#
Get the date of the next two days after one year:
[Email protected] ~]# date-d "Year 2 Day" +%y%m%d
20160821
[Email protected] ~]#
Get the date a week ago:
[Email protected] ~]# date-d "-1 weeks" +%y%m%d
20150812
[Email protected] ~]#
Get the day before the week before:
[Email protected] ~]# date-d "-1 weeks-1 days" +%y%m%d
20150811
[Email protected] ~]#
Get the date of the following day a week ago:
[[email protected] ~]# date-d "-1 weeks +1 days" +%y%m%d
20150813
[Email protected] ~]#
Get the date after one week:
[Email protected] ~]# date-d "Weeks" +%y%m%d
20150826
[Email protected] ~]#
Get the date of the next day after the week:
[Email protected] ~]# date-d "Week Day" +%y%m%d
20150827
[Email protected] ~]#
Get the date of the third day after one week:
[Email protected] ~]# date-d "Week 2 Day" +%y%m%d
20150828
[Email protected] ~]#
This article is from the "Pengcheng-soy sauce bottle" blog, please be sure to keep this source http://yfshare.blog.51cto.com/8611708/1687685
Get date in shell script