[英]Use of variable inside shell script
a="hello"
cat << EOF > abc.txt
Inside script $a
EOF
bash:找不到你好命令
當我嘗試在腳本 abc.txt 文件中使用a變量時出現此錯誤
正如@chepner 在評論中所說,你可能寫了
a= "hello"
代替
a="hello"
你可以看到下面的結果:
$ a= "hello"
-bash: hello: command not found
$ a="hello"
$
你總是可以在cat
之前放一個echo "______"
,然后你會看到錯誤在哪里(在echo
之前或之后)。
@Scott Hunter:錯誤並不是說它確實使用了變量a
。 根本沒有對變量a
引用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.