The following command issued from a terminal gets me yesterday’s date:
date --date='1 day ago' +%Y/%m/%d
I’m trying to write a bash script where the number of days is a command line arg. I’d like to be able to store the resulting date in another variable and use it later in my script. Thoughts?
Where
$1is the first command line argument. Make sure you use double-quotes instead of single quotes, other wise the argument isn’t expaneded.