[Shell] Linux date, get X days ago

I forget often these strings….

[code lang=”bash” autolinks=”false” collapse=”false” firstline=”1″ gutter=”true” htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false”]
date +"%Y%m%d" -d "91 days ago"
[ 20100701 ]

date -d "91 days ago"
[ Thu Jul  1 10:40:27 CEST 2010 ]

date +"%m-%d-%y" -d "91 days ago"
[ 07-01-10 ]

date +"%T"
[ 10:40:59 ]

#set variable
NOW=$(date +"%m-%d-%Y")
echo $NOW
[/code]

done.

 

Alberto Pasca

Software engineer @ Pirelli & C. S.p.A. with a strong passion for mobile  development, security, and connected things.