DCOM 142 FINAL Questions and Correct
Answers/ Latest Update / Already
Gradedt
What is the default mode "vi" text editor, when "vi" editor is entered
initially?
Ans: command
Which are two editors discussed in chapter 9 for writing shell scripts?
(choose two)
Ans: nano
vi
Which of the following are correct about for and while loops?
(choose two)
,2 | Page
Ans: for loops operate over a fixed list of items
while loops have a test each cycle to determine if it should run again
Which of the following statements acts as a good replacement of
the if-then-else-fi statement?
Ans: case
What is the purpose of conditional expressions in shell scripts?
Ans: They enable the script to take different actions in response to
variable data
Given the following script that is run through .test .sh hello goodbye:
if [ -f $2 ]; then echo "I am here" fi
Ans: If a file called "goodbye" exists in the current directory
What is the correct way to assign the word "Hello". to a variable?
,3 | Page
Ans: A="Hello"
Which shell command accepts input from the user's keyboard?
Ans: read
Given the following part of a script:
What is the meaning of $1?
if [-f$1 ]; then echo "I am here" fi
Ans: It is the first argument passed to the script
What is the effect of the following short script, cp1 if its called as cp1
big.c big.cc?
Ans: It copies the contents of big.cc to big.c eliminating the old big.c
Which of the following statements is included in a case statement to
denote the end of a case statement?
, 4 | Page
Ans: esac
What key(s) will enable insert mode in "vi" editor?
Ans: "i" key
What key(s) will you use to delete a line in "vi" editor?
Ans: "dd"
After using a text editor to create a shell script, what step should you
take before typing to use the script by typing its name?
Ans: Set one or more executable bits using chmod
Which of the following entries is maintained at the first line of the
bash script?
Ans: #!/bin/bash