Advance Bash Shell Scripting Quiz Questions and Answers

Which command is used to re-execute the previous command?

Answer :
  • !!

Explanation :

’!cat’ will reexecute the last cat command, ‘!3’ will reexecute the third last command and ‘!$’ will execute the last argument of previous command.

Which one of the following is not an environment variable?

Answer :
  • env

Explanation :

env is an external command which runs in a child process and it lists only environment variables which are inherited from its parent, the shell.

FC stands for?

Answer :
  • both find & fix command

Explanation :

’fc -l’ is used to list history of commands and ‘fc -e’ to edit them and ‘history’ command also provides the histroy of commands.

What is the syntax of array initialization when you are using the KSH shell?

Answer :
  • set -A array_name value1 value2 ... Valuen

Explanation :

If you are using the ksh shell, here is the syntax of array initialization : set -A array_name value1 value2 ... valuen.

The name of a variable can contain ________.

Answer :
  • A) numbers
    B) letters
    C) underscore
    All of the above

Explanation :

The name of a variable can contain only letters (a to z or A to Z), numbers ( 0 to 9) or the underscore character ( _).

Which keyword is used to remove the variable?

Answer :
  • unset

Explanation :

Unsetting or deleting a variable directs the shell to remove the variable from the list of variables that it tracks.

What is the syntax of array initialization when you are using bash shell?

Answer :
  • array_name=(value1 ... valuen)

Explanation :

If you are using the bash shell, here is the syntax of array initialization : array_name=(value1 ... valuen)

A shell variable is capable enough to hold a single value. These variables are called __________________.

Answer :
  • scalar variables

Explanation :

A shell variable is capable enough to hold a single value. These variables are called scalar variables.

Ctrl-Z key combination?

Answer :
  • stops the process running in the shell

Explanation :

Ctrl-Z key combination generates a SIGTSTP signal and stops the process running in the shell.

What is the syntax to access array values?

Answer :
  • ${array_name[index]}

Explanation :

After you have set any array variable, you access it as follows : ${array_name[index]}