Upwork (Odesk) UNIX SHELL SCRIPT TEST For 2016 - with 99% Results

Upwork UNIX SHELL SCRIPT TEST For 2016 with 99% Result



UNIX SHELL SCRIPT TEST of Latest version 2016. 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:
1.    <> 
2.    {}
3.    ( )
4.    &&
5.    %
2. A shell variable cannot start with:
Answers:
1.    An alphabet
2.    An underscore
3.    A number and an underscore
4.    An alphabet and an underscore
5.    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:
1.    Line 1 should be until=$1
2.    Until cannot be used as a variable name
3.    There is no error
4.    Line 4 should be echo “until cannot be used as a variable name”
5.    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 1
2.    2 2
3.    0 0
4.    0 1
5.    An error will occur
5. What is the output of the following program?
a=300
[ -n $a ]
echo $?
[ -z $a ]
echo $?
Answers:
1.    1 2
2.    0 2
3.    2 3
4.    0 0
5.    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:
1.    There is no error
2.    Line 4 should be echo x
3.    Test should be used on line 2 instead of []
4.    Line 1 should be x={10}
5.    Line 2 should be if [ $x -ge 2 ]
7. Which of the following is true about “until” loop?
Answers:
1.    The condition is tested at the end.
2.    It is executed as long as the given condition or list of items evaluate to true.
3.    It cannot test for conditions.
4.    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:
1.    0
2.    1
3.    2
4.    3
5.    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:
1.    x=3 y=1 z=1
2.    x=3 y=0 z=0
3.    x=3 y=3 z=5
4.    x=3 y=2 z=1
5.    None of the above
10. Which of the following statements is false?
Answers:
1.    Output of echo statement can be redirected to a file.
2.    Shell variables are case sensitive.
3.    Programs written for Bourne shell are compatible with Korn shell.
4.    expr can handle only integers.
5.    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:
1.    Diamond
2.    Spade
3.    Heart
4.    Club
5.    An error will occur
12. What would be the condition to check whether file with name “xyz” is a regular file?
Answers:
1.    if [ -f xyz ]
2.    if [ -d xyz ]
3.    if [ -v xyz ]
4.    if [ -r xyz ]
5.    if [ -e xyz ]
13. Which of the following statements is incorrect regarding if-then-fi?
Answers:
1.    It is a decision making construct.
2.    The group of commands between the then and else forms the if block.
3.    The else block is optional.
4.    The indentation is done in the if-then-fi to improve readability.
5.    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:
1.    0
2.    1
3.    2
4.    3
5.    4
15. Which of the following expressions is correct?
Answers:
1.    a=expr $b + $c
2.    a=`expr $b * $c`
3.    a=`expr $b * ( $c + $d )`
4.    a=expr $c * $d
5.    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:
1.    An error will occur
2.    No output will be displayed
3.    dog
4.    dog parrot cuckoo
5.    dog parrot cuckoo
17. Which of the following is true about the “continue” statement?
Answers:
1.    It cannot be used inside a loop.
2.    It continues the control to the beginning of the loop, bypassing the statements below it, inside the loop.
3.    It can only be used in a while loop.
4.    It has to be associated with an if statement.
5.    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.    1
2.    2
3.    3
4.    4
5.    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:
1.    There is no error
2.    Condition on line 1 is invalid
3.    Line 3 should be echo “false”
4.    Line 3 should be enclosed with {}
5.    Line 3 should be echo {false}
20. Which of the following assignments is illegal?
Answers:
1.    a=’cat file’
2.    b=100
3.    c=50
4.    d = 25
5.    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:
1.    An error will occur
2.    1
3.    2
4.    5
5.    10
22. The break statement is used to exit from:
Answers:
1.    the script.
2.    a “for” loop.
3.    an “if” statement.
4.    the shell.
5.    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:
1.    One cannot declare two variables on line 1
2.    Statements on lines 4 and 5 must appear with curly braces {}
3.    On line 2, test should be used instead of []
4.    There is no error
5.    On line 2 -ge should be used instead of >=
24. Precedence hierarchy decides which operator:
Answers:
1.    is used last.
2.    is used first.
3.    is unary type i.e. the operators that operate on single operand.
4.    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:
1.    An error will occur
2.    3 4 5
3.    2 2 2
4.    2 3 4
5.    1 1 1
26. The exit statement is used in a loop to:
Answers:
1.    exit from the “for” or “while” loop.
2.    exit from the “case” construct.
3.    terminate the execution of a script.
4.    exit from an “if” statement.
27. The expression expr -7 % 2 evaluates to:
Answers:
1.    0
2.    1
3.    -1
4.    2
5.    -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:
1.    There is no error
2.    Variable declaration on line 1 is incorrect
3.    The statement to be printed with echo on line 4 should be within curly brackets
4.    fi should be replaced by endif on line 5
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:
1.    An error will occur
2.    5
3.    e d c b a
4.    a b c d e
5.    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:
1.    0
2.    1
3.    2
4.    3
5.    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:
1.    Dec terminal
2.    Old terminal
3.    commonly used terminal
4.    vt series terminal
5.    Any terminal
32. Which of the following is not a shell keyword?
Answers:
1.    shift
2.    readonly
3.    ls
4.    unset
5.    echo
33. What is the error in the following loop statement?
while [ $1 -gt 10 -a ($2 -o -w $3 ) ]
Answers:
1.    There is no error
2.    ( ) brackets are to be used instead of []
3.    {} brackets are to be used instead of []
4.    One cannot use -gt and -o in the same expression
5.    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:
1.    0
2.    1
3.    2
4.    2.5
5.    3
35. The expression expr -2 % 7 evaluates to:
Answers:
1.    1
2.    2
3.    -2
4.    0
5.    0.285
36. Which of the following variable names is invalid?
Answers:
1.    _newvar
2.    variable
3.    #regpay
4.    expr
37. Which of the following assignments is illegal?
Answers:
1.    a=`ls`
2.    b=`ls -l`
3.    c=`1972`
4.    d=`who`
5.    e=`who | grep aa1`
38. On executing the statement:
set -3 + 1
Answers:
1.    $1 would be -3
2.    $1 would be 1
3.    $1 would be –
4.    $1 would be set
5.    An error would occur
39. Which of the following statements is true?
Answers:
1.    While executing a shell script, the shell acts as a compiler.
2.    Variables declared in a shell script can be displayed at the dollar prompt using the set command.
3.    There is no restriction on the length of a shell variable name.
4.    Any shell script by default gets executed in the current shell.
5.    A shell variable cannot hold negative values.
40. A shell script is executed by:
Answers:
1.    a code generator.
2.    an assembler.
3.    an interpreter./li>
4.    a compiler.
41. Which of the following is/are correct declaration(s) of a null variable “a” in shell script?
Answers:
1.    a=
2.    a= ”
3.    a= “”
4.    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:
1.    There is no error
2.    Line 1 should be j=$1
3.    Statements on lines 3 and 4 should be between curly brackets
4.    Line 4 should be echo {$j}
5.    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:
1.    An error will occur
2.    dog
3.    cuckoo
4.    cuckoo parrot dog
5.    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:
1.    5
2.    1 2 3 4 5
3.    a b c d e
4.    e d c b a
5.    An error will occur
6.    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:
1.    An error will occur
2.    Unix shell scripting
3.    Unix shell scripting
4.    shell
5.    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:
1.    There is no error.
2.    Variable declaration on line 1 is incorrect.
3.    The variables to be outputted on line 7 should be enclosed within quotes.
4.    Output will be 10 12 with a warning message in line 2
5.    fi should be replaced by endif on line 6
47. Which of the following loops is invalid?
Answers:
1.    while [ $? -eq 0 ]
2.    while [ $count -le 0.1]
3.    while [ $1 -gt 10]
4.    while [ 0 ]
5.    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:
1.    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.
2.    Only the first positional parameter would be shifted to left position.
3.    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.
4.    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.    1 and a warning about line 2 will occur
2.    3 and a warning about line 2 will occur
3.    5 and a warning about line 2 will occur
4.    10 and a warning about line 2 will occur
5.    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:
1.    any directory name
2.    cobol directory name
3.    fortran directory name
4.    pascal directory name
5.    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 1
2.    0 0
3.    0 1
4.    An error will occur
5.    A blank line will result
52. Which of the following expressions is valid?
Answers:
1.    t = 256 (space on both sides of ‘=’ operator)
2.    3.14 * $r * $r = area
3.    k=`expr a*b`
4.    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:
1.    It would not read any file
2.    It would read all the files in reverse order
3.    It would read only the test0.sh
4.    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.  Thank you very mutch for being with us.

Comments

Popular posts from this blog

Freelancer Wordpress Exam Answers 2016

100 percent Rank your website on Google for $13