Variable variable assignment error -“command not found”

= is an assignment operator when found free and $ holds value (not only in USA but in bash too) of a variable.

So when you say: $var=1, you’re essentially trying to type a random string (0=1 in your case) in bash and bash doesn’t like that. Look at the one-liner below that shows one example where you’d type in $var=1 and bash would be able to process it:

var=1; if [[ $var=1 ]]; then printf "Congrats! You have learned the difference between variable assignment and variable comparison in the ${var}st attempt.\n"; fi;

Leave a Comment