Присвоение значения артеметической операции

Что не так с моим кодом? Код, который я использовал:

a=4
b=$(expr $a % 2)

Когда я пытался отобразить b

$b
Bash: 0: command not found

Должен ли он быть один 0? Потому что у меня проблемы с использованием b в if выражении.

0
задан 25 July 2020 в 12:34

1 ответ

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.

0
ответ дан 30 July 2020 в 22:02

Другие вопросы по тегам:

Похожие вопросы: