Which of the following is not a valid command for variable declaration?

  • Post author:
  • Post category:Blog
  • Post last modified:September 22, 2023
  • Reading time:2 mins read

Which of the following is not a valid command for variable declaration?

  • export ENV_VAR=1
  • newvar -x ENV_VAR=1
  • typeset -x ENV_VAR=1
  • declare -x ENV_VAR=1
Explanation & Hint:

The command “newvar -x ENV_VAR=1” is not a valid command for variable declaration. The correct command for variable declaration and exporting it is the “export ENV_VAR=1” command.

The other options:

  1. export ENV_VAR=1: This is a valid command for declaring a variable and exporting it.
  2. typeset -x ENV_VAR=1: This is a valid command for declaring a variable and exporting it. In some shells, typeset is used instead of declare to define variables, and the -x flag indicates exporting.
  3. declare -x ENV_VAR=1: This is a valid command for declaring a variable and exporting it. The -x flag is used to indicate exporting the variable.

For more Questions and Answers:

NDG Introduction to Linux II 2.21 | Chapter 1: Advanced Shell Features Exam Answers