Что не так с моим кодом? Код, который я использовал:
a=4
b=$(expr $a % 2)
Когда я пытался отобразить b
$b
Bash: 0: command not found
Должен ли он быть один 0? Потому что у меня проблемы с использованием b
в if
выражении.
Your code is fine, it just that is not how you show the value of a variable.
$b
is just like entering the value of variable b and hitting enter as if that value was a bash command. That's why bash complains being unable to find the command "0".
Try this and see what happens:
x=ls
$ls
As the others said you can "show" the value of a variable b using
echo $b
Hope this helps.