Please answer the quiz and click the "Test" button at the bottom right.This quiz is part of the DevOpsTheHardWay course.
Bash - Variables - multichoice questions
Question 1
Which of the following commands would append the directory /opt/bin to the current value of the PATH environment variable?
-  
PATH=$PATH:/opt/bin -  
PATH+=/opt/bin -  
PATH=${PATH}+"/opt/bin" - A and B
 - All of the above
 
Question 2
Which of the following commands would create a file called jan_reports.txt?
-  
MONTH=jan; touch ${MONTH}_report.txt -  
MONTH=jan; touch $MONTH_report.txt -  
MONTH= jan; touch $MONTH_report.txt -  
MONTH= jan; touch $"MONTH"_report.txt - A and B
 
Question 3
Which command would display the current shell’s process id (pid)?
-  
echo $$ -  
echo $! -  
echo $PID -  
echo $BASH_PID - None of the above
 
Question 4
Which of the following is not a feature of environment variables?
- All processes use environment variables, not just those running the bash shell.
 - Environment variables are inherited by child processes by default.
 - Upon startup, the bash shell clears all previously defined environment variables.
 - Environment variables can be examined using files found in the /proc filesystem.
 - Environment variables possess all these features.
 
Question 5
Which ones(s) of the following would correctly set the shell variable ADDR to 123_Elm_St.?
-  
ADDR= 123_Elm_St. -  
ADDR = 123_Elm_St. -  
ADDR="123_Elm_St." -  
ADDR=123_Elm_St. - None of the above
 
Question 6
The user elvis performs the following command:
[elvis@station elvis]$ STYLE=terse
Which of the following commands could be used to examine the value of STYLE?
-  
set -  
env -  
cat /proc/$$/environ -  
export - A and C
 
Question 7
Which of the following command lines would create a file called make $ at home!?
-  
touch "make $ at home"\! -  
touch 'make $ at home!' -  
touch 'make $'\ at\ home\! - A and C
 - All of the above
 
Question 8
What is the output of this code?
VAR="/var/www/html/website.com/html/"
echo "${VAR#*/html}"
-  
/website.com/html/ -  
/html/website.com/html/ -  
/var/www/html/website.com/ - Nothing will be echoed on the screen.
 
Question 9
What is the output of this script?
#!/bin/bash
fname=john
john=thomas
echo ${!fname}
- john
 - thomas
 - Syntax error
 - blank
 
Question 10
When used from within a script, which variable contains the name of the script?
-  
$0 -  
$# -  
$$ -  
$@