選擇的結果之一,我想隨機選擇兩種結果之一SH #!/bin/sh
if [$[ $RANDOM % 2] -eq 1 ]
then
echo yes
else
echo no
fi
給 sh-3.2$ sh test.sh
test.bash: line 4: [1: command not found
no
顯然,它試圖執行(0,1 )作爲命令。我究竟做錯了什麼?
我有一個shell腳本,我在其中包裝命令(mvn clean install),將輸出重定向到日誌文件。 #!/bin/bash
...
mvn clean install [email protected] | tee $logfile
echo $? # Does not show the return code of mvn clean install
現在如果mvn clean