0
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

3
  • 2
    Cannot reproduce. That code would not try to execute the value of $a as a command. Commented Jan 12, 2023 at 17:43
  • 2
    Did you actually write something like a= "hello" instead? Commented Jan 12, 2023 at 17:43
  • The error is saying that it did use the variable, but couldn't find the command with that name. Commented Jan 12, 2023 at 17:43

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.