Question: The candidate s attention is drawn to the shell syntax summary document which is attached after the end of the examination paper. Q 1 .

The candidates attention is drawn to the shell syntax summary document which is attached
after the end of the examination paper.
Q1.(a) A shell variable FULLUSERNAME has the value
King James I, James VI of Scotland
There are no leading or trailing spaces, and there are four spaces following the
comma. Write out the result of executing the following shell commands. In each
case be sure to indicate exactly what would be printed including the presence
and quantity of space characters.
i. echo FULLUSERNAME [2]
ii. echo $FULLUSERNAME [2]
iii. echo "$FULLUSERNAME" [2]
iv. echo '$FULLUSERNAME' [2]
(b) Consider the following statements which are exectued in a bash shell. Assume
that the shells internal field separator variable, IFS, is set to its default value.
showargs (){
for a in "$@" ; do
echo "$a"
done
}
i. What is printed when showargs My name is Bond. "James Bond." is
executed? Explain your reasoning. [4]
ii. The quotation marks are removed from around the $@ and the same command is executed. What is printed now? Explain the differences, if
any. [4]
iii. The quotation marks are restored and the "$@" replaced with "$*". The
same command is executed once more. Explain the difference in output
compared with the first time the function was invoked, if any. [4]
(c) In bash, the return command provides a return condition to the caller and
can only pass integers. Using an example, explain how a string value generated
by a funciton can be used by the caller.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!