Home > Software design >  Use of variable inside shell script
Use of variable inside shell script

Time:01-13

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

CodePudding user response:

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.

  • Related