简体   繁体   中英

Use of variable inside shell script

a="hello" 
cat << EOF > abc.txt
Inside script $a
EOF

bash: hello command not found

I got this error when I try to use the a variable inside the script abc.txt file

As @chepner said in the comments, you probably wrote

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 ).

@Scott Hunter: The error is not saying that it did use the variable a . There is no reference at all to the variable a .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM