[英]Use of variable inside shell script
a="hello"
cat << EOF > abc.txt
Inside script $a
EOF
bash: hello command not found
bash:找不到你好命令
I got this error when I try to use the a variable inside the script abc.txt file当我尝试在脚本 abc.txt 文件中使用a变量时出现此错误
As @chepner said in the comments, you probably wrote正如@chepner 在评论中所说,你可能写了
a= "hello"
instead of代替
a="hello"
You can see the result below:你可以看到下面的结果:
$ a= "hello"
-bash: hello: command not found
$ a="hello"
$
You can always put an echo "______"
before the cat
, and then you will see where the error is (before or after the echo
).你总是可以在
cat
之前放一个echo "______"
,然后你会看到错误在哪里(在echo
之前或之后)。
@Scott Hunter: The error is not saying that it did use the variable a
. @Scott Hunter:错误并不是说它确实使用了变量
a
。 There is no reference at all to the variable a
.根本没有对变量
a
引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.