WorksheetsSLG ULI101 Week 11 - Bash Scripting
Total questions: 15
Worksheet time: 14mins
What is the significance of $#?
Shows the Process ID of the current script.
Shows the count of the arguments passed to the script.
Shows the end status of the last process to execute.
Returns the current line number of the script.
What is the significance of $?
It gives more details about the ? command
It shows Variable $
It gives the exit status of the last command that was executed.
It is used with echo to show the current status of the echo command
What is the significance of this line "#! /bin/bash"
Is used on top of a script file to determine the output of the script
Instructs the user not to use /bin/bash
Determines the location of the engine which is to be used to execute the script
Its used to make the script look prettier
Which option will cause the echo command NOT to output a trailing newline?
-e
-p
-n
-s
Which command shows if /usr/bin is in the current shell search path?
cat PATH
echo $PATH
echo %PATH
cat $PATH
echo %PATH%
How is it possible to determine if an executable file is a shell script which is read by Bash?
The r bit is set.
The file must end with .sh.
The first line starts with #!/bin/bash.
/bin/bash has to be run in debug mode.
Scripts are never executable files.
Which of the following statements may be used to access the second command line argument to a script?
"$ARG2"
$1
"$2"
"$1"
'$2'
What keyword is missing from the following segment of the shell script?
for i in *
_____
cat $i
done
do
then
enod
fi
run
What is the output of the following script?
for token in a b c
do
echo -n "$token";
done
anbncn
abc
$token$token$token
a
b
c
a b c
What keyword is used in a bash script to begin a loop?
elif
else
for
if
A directory contains the following files:
a.txt
b.txt
c.cav
What would be the output of the following bash script?
for file in *.txt
do
echo $file
done
*.txt
a b
c.cav
a.txt
a. txt
b. txt
If a grep match returned two lines, what will echo $? return?
0
2
1
Nothing
Using bash, check if $result is less than 20.
(a)
In bash what does fi mean or what is it for?
