I have a script that kicks off a database query dependent on dates. Right now, the script defaults to yesterday's date:
function startDate() {
date --date="yesterday" "+%Y-%m-%d";
}
START= "`startDate`"
What I want to do is pass an argument to the script, so that cron (or whatnot) can have configurable dates. I am unable to get the right syntax for neither the function nor the function call:
function startDate() {
if [ -z "$1" ]
then
date --date="yesterday" "+%Y-%m-%d";
else
"$1"
fi
}
START= "`startDate \"$1\"`"
$ sh shTest.sh 2014-05-19
shTest.sh: line 6: 2014-05-19: command not found
shTest.sh: line 10: : command not found
What am I missing here?