I need a small correction for my below code. I am trying to assign variable value to another variable, but it's not working. please help me.
Below is my script.
#!/bin/sh
choice=1
VAL1="test"
if [ "$choice" == 1 ];
then
echo "insode"
echo $choice
purpose=$VAl1
echo "*"
echo $purpose
fi
Please help me, I'm new to shell scripting. I need to display purpose
value as test.
You assign a value to VAL1
:
VAL1="test"
But later you assign $VAl1
to purpose
:
purpose=$VAl1
You just have to fix the case so the variable names match (fix lowercase l
to uppercase L
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.