153k views
2 votes
Which of these is NOT a valid variable in bash?

1) __ (double underscore)
2) _1var (underscore 1 var)
3) _var_ (underscore var underscore)

User Ianmclaury
by
8.2k points

1 Answer

6 votes

Final answer:

All the given options (__ , _1var, _var_) are valid variable names in Bash according to the naming conventions where a variable may consist of alphanumeric characters and underscores, beginning with a letter or underscore.

Step-by-step explanation:

In Bash, variable names may consist only of alphanumeric characters and underscores. They must start with either a letter or an underscore. Considering this, let's analyze the given options:

  • __ (double underscore) is a valid variable name.
  • _1var (underscore 1 var) is a valid variable name.
  • _var_ (underscore var underscore) is also a valid variable name.

All of the options presented are valid variable names in Bash. Therefore, there is no incorrect option listed based on Bash's variable naming conventions.

User Mpskovvang
by
7.6k points