大家好,我是 shell 腳本的新手,我嘗試運行下面的腳本,但出現以下錯誤訊息:
#!/bin/bash
echo "Enter the name of the image whose container you want to run: "
read container
echo "Enter a name for this container: "
read name
echo "do you want to run in detatch mode? "
read d
if [ $d -eq yes ]
then
docker run --name $name -P -d $container
elif [ $d -eq no ]
then
docker run --name $name -P $container
else
echo "invalid input"
fi
這會產生以下錯誤訊息:
./main.sh: line 9: [: yes: integer expression expected
./main.sh: line 12: [: yes: integer expression expected
uj5u.com熱心網友回復:
-eq比較兩個整數用于=比較兩個字串以獲取更多資訊,請參閱:https ://stackoverflow.com/a/20449556/9881735
例如:
[ $d = "yes" ]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/493727.html
