Hello Freelancer, Get the UNIX SHELL SCRIPT TEST of Latest version 2018. We are ready here to provide your desire upwork test answer. We already tested all exam test information Available include on here. So Dear, Why Late? Read the below full exam test and get more information from our website.
1. Which of the following is/are allowed in an arithmetic statement involving expr command?
Answers:
- <>
- {}
- ( )
- &&
- %
2. A shell variable cannot start with:
Answers:
- An alphabet
- An underscore
- A number and an underscore
- An alphabet and an underscore
- A number and a special symbol other than the underscore
3. What is the error in the following shell script code?
1. until=1
2. while [ $until -eq 5 ]
3. do
4. echo until cannot be used as a variable name
5. until=`expr $until + 1`
6. done
Answers:
- Line 1 should be until=$1
- Until cannot be used as a variable name
- There is no error
- Line 4 should be echo “until cannot be used as a variable name”
- Line 4 should be enclosed within { }
4. What is the output of the following program?
b=
[ -n $b ]
echo $?
[ -z $b ]
echo $?
Answers:
- 1 1
- 2 2
- 0 0
- 0 1
- An error will occur
5. What is the output of the following program?
a=300
[ -n $a ]
echo $?
[ -z $a ]
echo $?
Answers:
- 1 2
- 0 2
- 2 3
- 0 0
- 0 1
6. What is the error in the following program?
1. x=10
2. if [ x -ge 2 ]
3. then
4. echo $x
5. fi
Answers:
- There is no error
- Line 4 should be echo x
- Test should be used on line 2 instead of []
- Line 1 should be x={10}
- Line 2 should be if [ $x -ge 2 ]
7. Which of the following is true about “until” loop?
Answers:
- The condition is tested at the end.
- It is executed as long as the given condition or list of items evaluate to true.
- It cannot test for conditions.
- We cannot use exit statement under until loop.
8. If x=11 and y=6, then what is the exit status of the following expression?
[ ! $x -gt 9 -a ! $y -ne 23 ]
Answers:
- 0
- 1
- 2
- 3
- 4
9. What is the output of the following program?
x=3
y='[$x -eq 10 ]’
z='[$x -lt 10 ]’
echo x=$x y=$y z=$z
Answers:
- x=3 y=1 z=1
- x=3 y=0 z=0
- x=3 y=3 z=5
- x=3 y=2 z=1
- None of the above
10. Which of the following statements is false?
Answers:
- Output of echo statement can be redirected to a file.
- Shell variables are case sensitive.
- Programs written for Bourne shell are compatible with Korn shell.
- expr can handle only integers.
- Comments can be split over multiple lines if each line is preceded by #.
11. What is the output of the following shell script code?
suite=3
case $suite in
1) echo Diamond ;;
2) echo Spade ;;
3) echo Heart ;;
4) echo Club ;;
esac
Answers:
- Diamond
- Spade
- Heart
- Club
- An error will occur
12. What would be the condition to check whether file with name “xyz” is a regular file?
Answers:
- if [ -f xyz ]
- if [ -d xyz ]
- if [ -v xyz ]
- if [ -r xyz ]
- if [ -e xyz ]
13. Which of the following statements is incorrect regarding if-then-fi?
Answers:
- It is a decision making construct.
- The group of commands between the then and else forms the if block.
- The else block is optional.
- The indentation is done in the if-then-fi to improve readability.
- The indentation is mandatory otherwise an error will occur on execution.
14. If x=11 and y=6, then what is the exit status of the following expression?
[ $x -eq 11 -a $y -ne 89 ]
Answers:
- 0
- 1
- 2
- 3
- 4
15. Which of the following expressions is correct?
Answers:
- a=expr $b + $c
- a=`expr $b * $c`
- a=`expr $b * ( $c + $d )`
- a=expr $c * $d
- a=`expr $b * ( $c + $d )`
16. What will be the output of the following program assuming that the command line arguments are dog parrot cuckoo?
for argument in “$*”
do
echo $argument
done
Answers:
- An error will occur
- No output will be displayed
- dog
- dog parrot cuckoo
- dog parrot cuckoo
17. Which of the following is true about the “continue” statement?
Answers:
- It cannot be used inside a loop.
- It continues the control to the beginning of the loop, bypassing the statements below it, inside the loop.
- It can only be used in a while loop.
- It has to be associated with an if statement.
- It is used with the case construct.
18. Which of the following lines have an error?
1. echo enter your name
2. read filename
3. read name < $filename
4. echo $name
Answers:
- 1
- 2
- 3
- 4
- There is no error.
19. What is the error in the following program?
1. while who | grep aa12 | wc -l
2. do
3. echo false
4. done
Answers:
- There is no error
- Condition on line 1 is invalid
- Line 3 should be echo “false”
- Line 3 should be enclosed with {}
- Line 3 should be echo {false}
20. Which of the following assignments is illegal?
Answers:
- a=’cat file’
- b=100
- c=50
- d = 25
- e=’ls’
21. What is the output of the following program?
i=1
for [ i -le 10 ]
do
echo $i
i=’expr $i + 1′
done
Answers:
- An error will occur
- 1
- 2
- 5
- 10
22. The break statement is used to exit from:
Answers:
- the script.
- a “for” loop.
- an “if” statement.
- the shell.
- the “case” construct.
23. What is the error in the following program?
1. j=10 k=12
2. if [ $k>=$j ]
3. then
4. k=$j
5. j=$k
6. fi
7. echo $j $k
Answers:
- One cannot declare two variables on line 1
- Statements on lines 4 and 5 must appear with curly braces {}
- On line 2, test should be used instead of []
- There is no error
- On line 2 -ge should be used instead of >=
24. Precedence hierarchy decides which operator:
Answers:
- is used last.
- is used first.
- is unary type i.e. the operators that operate on single operand.
- is binary type i.e. the operators that operate on two operands.
25. What is the output of the following program?
i=1 j=1 k=1
while [ $i -lt 10 ]
do
while [ $j -lt 10 ]
do
while [ $k -lt 10 ]
do
echo $i $j $k
k=’expr $k + 1′
break 3
done
j=’expr $j + 1′
done
i=’expr $i + 1′
done
Answers:
- An error will occur
- 3 4 5
- 2 2 2
- 2 3 4
- 1 1 1
26. The exit statement is used in a loop to:
Answers:
- exit from the “for” or “while” loop.
- exit from the “case” construct.
- terminate the execution of a script.
- exit from an “if” statement.
27. The expression expr -7 % 2 evaluates to:
Answers:
- 0
- 1
- -1
- 2
- -2
28. What is the error in the following shell script code?
#!/bin/sh
1. a=12.25 b=12.52
2. if [a=b]
3. then
4. echo “na and b are equal”
5. fi
Answers:
- There is no error
- Variable declaration on line 1 is incorrect
- The statement to be printed with echo on line 4 should be within curly brackets
- fi should be replaced by endif on line 5
- On line 2, [a=b] should be replaced with [ $a -eq $b ]
29. What is the output of the following program?
for i in ‘a b c d e’
do
echo $i
done
Answers:
- An error will occur
- 5
- e d c b a
- a b c d e
- a b c d e
30. What is the output of the following program?
i=4 z=12
[ $i = 5 -a $z -gt 5 ]
echo $?
Answers:
- 0
- 1
- 2
- 3
- 4
31. What is the output of the following program?
terminal=vt100
case $terminal in
vt100) echo Dec terminal;;
vt200) echo Old terminal;;
ansi) echo Commonly used terminal;;
v*) echo vt series terminal;;
*) echo Any terminal;;
esac
Answers:
- Dec terminal
- Old terminal
- commonly used terminal
- vt series terminal
- Any terminal
32. Which of the following is not a shell keyword?
Answers:
- shift
- readonly
- ls
- unset
- echo
33. What is the error in the following loop statement?
while [ $1 -gt 10 -a ($2 -o -w $3 ) ]
Answers:
- There is no error
- ( ) brackets are to be used instead of []
- {} brackets are to be used instead of []
- One cannot use -gt and -o in the same expression
- One cannot use -o and -w in the same expression
34. The statement z=`expr 5 / 2` would store which of the following values in z?
Answers:
- 0
- 1
- 2
- 2.5
- 3
35. The expression expr -2 % 7 evaluates to:
Answers:
- 1
- 2
- -2
- 0
- 0.285
36. Which of the following variable names is invalid?
Answers:
- _newvar
- variable
- #regpay
- expr
37. Which of the following assignments is illegal?
Answers:
- a=`ls`
- b=`ls -l`
- c=`1972`
- d=`who`
- e=`who | grep aa1`
38. On executing the statement:
set -3 + 1
Answers:
- $1 would be -3
- $1 would be 1
- $1 would be –
- $1 would be set
- An error would occur
39. Which of the following statements is true?
Answers:
- While executing a shell script, the shell acts as a compiler.
- Variables declared in a shell script can be displayed at the dollar prompt using the set command.
- There is no restriction on the length of a shell variable name.
- Any shell script by default gets executed in the current shell.
- A shell variable cannot hold negative values.
40. A shell script is executed by:
Answers:
- a code generator.
- an assembler.
- an interpreter./li>
- a compiler.
41. Which of the following is/are correct declaration(s) of a null variable “a” in shell script?
Answers:
- a=
- a= ”
- a= “”
- All of the above.
42. What is the error in the following program?
1. j=1
2. while [ $j -le 10 ]
3. do
4. echo $j
5. j = j + 1
6. done
Answers:
- There is no error
- Line 1 should be j=$1
- Statements on lines 3 and 4 should be between curly brackets
- Line 4 should be echo {$j}
- Line 5 should be j=`expr $j + 1`
43. What will be the output of the following program assuming that the command line arguments are dog parrot cuckoo?
for argument in $*
do
echo $argument
done
Answers:
- An error will occur
- dog
- cuckoo
- cuckoo parrot dog
- dog parrot cuckoo
44. What is the output of the following program?
for i in a b c d e
do
echo $i
done
Answers:
- 5
- 1 2 3 4 5
- a b c d e
- e d c b a
- An error will occur
- a b c d e
45. What will be the output of the following program assuming that the command line arguments are Unix shell scripting?
for argument in *
do
echo $argument
done
Answers:
- An error will occur
- Unix shell scripting
- Unix shell scripting
- shell
- The names of all files in the current directory would be displayed
46. What is the error in the following program?
1. j=10 k=12
2. if test [ $k -ge $j ]
3. then
4. k=$j
5. j=$k
6. fi
7. echo $j $k
Answers:
- There is no error.
- Variable declaration on line 1 is incorrect.
- The variables to be outputted on line 7 should be enclosed within quotes.
- Output will be 10 12 with a warning message in line 2
- fi should be replaced by endif on line 6
47. Which of the following loops is invalid?
Answers:
- while [ $? -eq 0 ]
- while [ $count -le 0.1]
- while [ $1 -gt 10]
- while [ 0 ]
- while $
48. Suppose you are writing a shell script that accepts five positional parameters from the terminal. What will be the effect of using statement “shift 1” in your shell script and then executing the shell script?
Answers:
- The positional parameters would be shifted by one position towards left i.e. parameter 1 will have value of parameter 2, parameter 2 will have value of parameter 3 and so on.
- Only the first positional parameter would be shifted to left position.
- All of the positional parameters would be shifted by one position towards right i.e. parameter 2 will have value of parameter 3, parameter 3 will have value of parameter 4 and so on.
- It would result in an error.
49. What is the output of the following program?
1. x=3 y=5 z=10
2. if [ ($x -eq 3) -a ( $y -eq 5 -o $z -eq 10 ) ]
3. then
4. echo $x
5. else
6. echo $y
7. fi
Answers:
- 1 and a warning about line 2 will occur
- 3 and a warning about line 2 will occur
- 5 and a warning about line 2 will occur
- 10 and a warning about line 2 will occur
- An error will occur
50. What is the output of the following program when directory name “home” is given as input?
echo Enter a directory Name
read dirname
case $dirname in
*) echo any directory name ;;
c*) echo cobol directory name ;;
f*) echo fortran directory name ;;
p*) echo pascal directory name ;;
esac
Answers:
- any directory name
- cobol directory name
- fortran directory name
- pascal directory name
- An error will occur
51. What is the output of the following program?
k=35
echo `[ $k -eq 35 ]“[ $k -eq 50 ]`
Answers:
- 1 1
- 0 0
- 0 1
- An error will occur
- A blank line will result
52. Which of the following expressions is valid?
Answers:
- t = 256 (space on both sides of ‘=’ operator)
- 3.14 * $r * $r = area
- k=`expr a*b`
- tput cup $row $col
53. Suppose there are three files test0.sh, test1.sh, and test2.sh in your current directory. Which of the following options would occur during the execution of read statement?
exec < test0.sh
exec < test2.sh
exec < test3.sh
read line
echo $line
Answers:
- It would not read any file
- It would read all the files in reverse order
- It would read only the test0.sh
- It would read only test3.sh
Finally, no more words require about the UNIX SHELL SCRIPT TEST information in this session of this content. If you are require knowing more, Please ask to us via our contact us form or comment box. Please make sure that, you don’t send Personal information via the Comment box. Thanks for Being with us.
No comments:
Post a Comment