lundi 27 juin 2016

Modifying variable inside if-then-elif is not remembered [duplicate]

This question already has an answer here:

I am trying to take a case-insensitive input from user, but set a specific case value to variable, in the following shell script. But i get an error host: command not found I know that loops are executed in subshell, but am not sure about if-then-elif. I am a beginner in shell scripting and don't know how to set target variable in if-then-elif

if [ "${target,,}" = "host" ]; then
    target = "Host"
elif [ "${target,,}" = "device" ]; then
    target = "Device"   
elif [ "${target,,}" = "bb" ]; then
    target = "BB"
else 
    echo " $LINENO: Target not supported"
fi

How should i implement the script so that the variable is set properly?

Aucun commentaire:

Enregistrer un commentaire