shell script gets today, yesterday and the day before yesterday and the day before the date n



1, today's date acquired

log = $ (DATE -d "now" M-%% +% Y-D)
echo log {} $

2, yesterday's date acquired
log2 = $ (date -d "yesterday " +% Y -% M-% D)
echo $} {Iog2

or

Iog2 = $ (dATE -d ". 1 Day ago Member" M-%% +% Y-D)
echo $ {Iog2}

. 3, the day before the date acquired
log3 = $ ( -d dATE "2 Day ago Member" M-%% +% Y-D)
echo log3 the $ {}

. 4, a few days before the specific date acquired

log4 = $ (date -d "15 day ago 2017-04-16" + % Y-M-% D%)

echo $ {} log4
output: 2017-04-01
----------------

description link: https: //blog.csdn.net/ qq_24309787 / article / details / 93851744

Guess you like

Origin www.cnblogs.com/walkersss/p/12143096.html