Bash Date - n days

enthuguy used Ask the Experts™
Hi experts.

could you kindly to get current date - 45 days in below format please

Basically would like to go back 45 days

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017
IN what circumstance?
just would like to store the (current date - 45) into a variable with above format :)
Sr. Systems Administrator
try this

DATE=`date --date="45 day ago" +%Y-%m-%d`
echo $DATE

Open in new window


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial