trying to make a bash script that sets a value for use later in the script, depending on what I send when I run it; i.e. ./script.sh 24
code:
### Setting values depending on input
#
# If value is between 7 and 13
if [[ $1 -le 13 || $1 -ge 7 ]]; then
#set value to
VALUE=7
# else if value is between 14 and 29
elif [[ $1 -le 29 || $1 -ge 14 ]]; then
#else set value to
VALUE=14
# else if value is larger than 30
elif [[ $1 -le 30 ]]; then
#Set value to VALUE=30
#else
# echo nope
fi
# This is just for showing what's going on
echo "input: $1"; echo "value: $VALUE"
# Do other stuff here...
But I can't get it to work properly, it only sets "value" to 7, no matter what i send on script start. Does bash read values in any special order? When I run it with ./script.sh 24 I gives "value=7" but it (in my mind) should be "value=14"
Aucun commentaire:
Enregistrer un commentaire