Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Variable not found" error issued by the shell

if [ "$1" = "" ]
then
       echo -n "Gib das Startkapital ein: "
       read kapital
else
       kapital  = $1
fi

echo $kapital

When I say kapital = $1 it says that this variable does not exist:

$ sh zins.sh
zins.sh: 16: zins.sh kapital: not found
like image 423
igodie Avatar asked Dec 08 '16 17:12

igodie


1 Answers

Unlike free-format languages like C, the shell is white-space sensitive in many places, and one of them is the = in assignments. Use

kapital=$1

and it will work.

like image 129
Jens Avatar answered Oct 11 '22 00:10

Jens