tags:

views:

80

answers:

1

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?

+2  A: 
    x=$(date --date "$1 days ago" +%Y/%m/%d)

Where $1 is the first command line argument. Make sure you use double-quotes instead of single quotes, other wise the argument isn't expaneded.

eduffy
damn... I just had the wrong damn quotes... thanks
fmpdmb