1
我有一個腳本,啓動依賴日期的數據庫查詢。眼下,腳本默認爲昨天的日期:設置Bash腳本變量等於函數參數
function startDate() {
date --date="yesterday" "+%Y-%m-%d";
}
START= "`startDate`"
我想要做的就是參數傳遞給腳本,這樣的cron(或諸如此類的東西)可以有可配置的日期。我無法得到正確的語法無論是功能還是函數調用:
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
缺少什麼我在這裏?