变量变量分配错误-“未找到命令"; [英] Variable variable assignment error -"command not found"
本文介绍了变量变量分配错误-“未找到命令";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行脚本时,出现以下错误.请问我在这里做错了什么?任何帮助表示赞赏-Bash新手
When I run the script I get the following errors. What am I doing wrong here please? Any help appreciated- Bash Newbie
错误:
line 12: 0=1: command not found
line 13: 0=1: command not found
我的脚本:
count_raw=0
avg_raw=0
$count_raw=1
$avg_raw=1
echo "count_raw=$count_raw"
echo "avg_raw=$avg_raw"
推荐答案
=
是赋值运算符,当发现它是免费的并且$
拥有变量的值(不仅在美国,而且在bash中).
=
is an assignment operator when found free and $
holds value (not only in USA but in bash too) of a variable.
因此,当您说:$var=1
时,您实际上是在尝试在bash中键入随机字符串(在您的情况下为0=1
),而bash不喜欢那样.请看下面的单行代码,该代码显示了一个示例,您可以在其中键入$var=1
,bash可以对其进行处理:
So when you say: $var=1
, you're essentially trying to type a random string (0=1
in your case) in bash and bash doesn't like that. Look at the one-liner below that shows one example where you'd type in $var=1
and bash would be able to process it:
var=1; if [[ $var=1 ]]; then printf "Congrats! You have learned the difference between variable assignment and variable comparison in the ${var}st attempt.\n"; fi;
这篇关于变量变量分配错误-“未找到命令";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文