I've given a variable which hold a numberdaysAgo=1I would like to expand this variable in a get date expression. Like this:$(date +%d -d '$daysAgo days ago')What do I need to do that the $daysAgo variable gets expanded?I tried like that without success:daysAgo=1exp='${daysAgo} days ago'$(date +%d -d $exp)
How to insert variable in get date expression?
bash;date;variable
Just use , not '. Double quotes allows expansion of variables within the quotes, single quotes dont. daysAgo=1echo $(date +%d -d $daysAgo day ago)06daysAgo=1exp=$daysAgo days agoecho $(date +%d -d $exp)06