Interview Prep/Shell Scripting/Variables, quoting and expansions

What are the rules for assigning variables in Bash?

BeginnerConceptVariables, quoting and expansions
Answer

No spaces around =. name=value assigns; name = value runs a command named name with arguments = and value. Names are letters, digits and underscores, not starting with a digit. The right side does not undergo word splitting or globbing, but quoting it is still a good habit.

APP_DIR=/srv/app
release="$(date +%Y%m%d%H%M%S)"
msg="deploy of ${release} started"

Use lowercase for script-local variables and UPPERCASE for exported/environment ones, so you never clobber PATH, HOME or USER by accident.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Variables, quoting and expansions