I'm a newby on bash scripting and need help.
I've made script that needs to compare a user input (fixed choices for 045, 046, 287 or 279). With other values.
When the user inputs 045 or 046 then the if statement is true and should display
You have choosen $SID. Menu 1 will be used
If the user inputs 287 or 279 the statement need to false and display
You have choosen $SID. Menu 2 will be used
$SID is the user input given above.
if [ "$SID" == "046" -o "045" ] ; then
printf "You have choosen $SID. Menu 1 will be used"
else
printf "You have choosen $SID. Menu 2 will be used"
fi
But when running the script it always displays the true statement with the users input displayed on the $SID location.
You have choosen 045. Menu 1 will be used
You have choosen 046. Menu 1 will be used
You have choosen 287. Menu 1 will be used
You have choosen 279. Menu 1 will be used
What I would expect is this:
When 045 or 046 is used:
You have choosen 045. Menu 1 will be used
You have choosen 046. Menu 1 will be used
When 279 or 287 is used:
You have choosen 287. Menu 2 will be used
You have choosen 279. Menu 2 will be used
I also tried the following if statement without results:
if [ $SID -eq 046 -o 045 ] ; then
if [ "$SID" -eq "046" -o "045" ] ; then
if [ $SID = 046 -o 045 ] ; then
if [ "$SID" = "046" -o "045" ] ; then
What am I missing?
Aucun commentaire:
Enregistrer un commentaire