0% found this document useful (0 votes)
38 views10 pages

Unix Module 4 MCQ

Uploaded by

Chintan S Gowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views10 pages

Unix Module 4 MCQ

Uploaded by

Chintan S Gowda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Module-4

Introduction to the Shell Scripting


MCQ’S
1. Which of the following is not a type of shell?

A. The C Shell
B. The Korn Shell
C. The Bourne Shell
D. The Perl Shell

2. Which of the following is true about shell?

A. A Shell provides you with an interface to the Unix system.


B. Shell gathers input from you and executes programs based on that input.
C. Shell is an environment in which we can run our commands, programs, and
shell scripts.
D. All of the above

3. The original Unix shell was written by __________.

A. Stephen R. Bourne
B. Stephen R. Korn
C. Stephen R. C.
D. Stephen Watson

4. On a UNIX system, there can be ____ shells running simultaneously.

A. 2
B. 3
C. 4
D. Many

5. The prompt issued by the shell is called ______

A. prompt
B. command translator
C. command prompt
D. command executor

6. In UNIX there are ___ major types of shells.

A. 2
B. 3
C. 4
D. 5

7. What is the default symbol for command prompt in Bourne shell?

A. !
B. #
C. $
D. @

8. Which shell is the most common and best to use?

A. Korn shell
B. C shell
C. Bourne shell
D. Bash Shell

9. The name of a variable can contain ________.

A. numbers
B. letters
C. underscore character
D. All of the above

10. Unix shell variables will have their names in _____.

A. Uppercase
B. Lowercase
C. First character Uppercase and all other character Lowercase
D. First character Lowercase and all other character Uppercase

11. Whch of the following is invalid variable names?


A. VAR_1
B. _ALI
C. VAR1
D. VAR_A!

12. Shell variables are of ____ types.

A. 3
B. 4
C. 2
D. 5

13. Which of the following command is used to display the environment variables
only?

A. sh
B. set
C. env
D. var

14. How many prompt shell has?

A. 4
B. 2
C. 3
D. 5

15. We cannot use the unset command to unset variables that are marked
____________.

A. read
B. write
C. readonly
D. writeonly

16. Which one of the following is not an environment variable?

A. env
B. Path
C. Home
D. User

17. $# is used to show?

A. The number of arguments supplied to a script.


B. The filename of the current script.
C. The exit status of the last command executed.
D. The process number of the last background command

18. Which of the following operator is not supported in Bourne shell?

A. Arithmetic Operators
B. Boolean Operators
C. Character operators
D. File Test Operators

19. The complete expr and awk expression should be enclosed between
___________.

A. ()
B. " "
C. ' '
D. < >

20. In relational operator, which keyword is used to represent greater than or


equal?

A. -eq
B. -gte
C. -ge
D. –gt

21. Which of the boolean operator is supported in bourne shell?

A. and
B. or
C. not
D. All of the above
22. Which of the following loops is not available in shell?

A. The for loop


B. The until loop
C. The select loop
D. The foreach loop

23. The _______ loop executes the given commands until the given condition
remains true.

A. For loop
B. While loop
C. until loop
D. Both B and C

24. Which of the following statements that are used to control shell loops?

A. break
B. continue
C. Both A and B
D. None of the above

25. A loop may continue forever if the required condition is not met is known as
____________.

A. finite loop
B. infinite loop
C. simple loop
D. definate loop

26. Which of the following statement is used to terminate the execution of the
entire loop?

A. continue
B. terminate
C. this
D. break

27. Which of the following statement is supported in unix shell?


A. case
B. Switch
C. switch...case
D. case...esac

28. Continue statment cannot be used in which loop?

A. For loop
B. until loop
C. while loop
D. case...esac

29. Which of the following statement causes the current iteration of the loop to
exit, rather than the entire loop?

A. Continue
B. break
C. return
D. goto

30. What is the syntax of continue statement?

A. continue
B. continue n
C. continue this
D. All of the above

Answers:

1. Ans : D

Explanation: The Perl shell is not a type of shell in unix


2. Ans : D

Explanation: All of the above statement are true about shell.


3. Ans : A

Explanation: The original Unix shell was written in the mid-1970s by


Stephen R. Bourne

4. Ans : D

Explanation: On a UNIX system, there can be many shells running


simultaneously.

5. Ans : C

Explanation: The prompt issued by the shell is called a command prompt


which is represented by $.

6. Ans : A

Explanation: In UNIX, there are two major types of shells : Bourne shell and
C shell.

7. Ans : C

Explanation: If we are using bourne shell on our system, then the default
prompt will be represented by $.

8. Ans : D

Explanation: Bash is near POSIX-compliant and probably the best shell to


use.

9. Ans : D

Explanation: The name of a variable can contain only letters (a to z or A to


Z), numbers ( 0 to 9) or the underscore character ( _).

10. Ans : A

Explanation: Unix shell variables will have their names in UPPERCASE.


11. Ans : D

Explanation: VAR_A! is invalid variable names.

12. Ans : C

Explanation: Shell variables are of two types : local and environment.

13. Ans : C

Explanation: env command is used to display environment variables only in


the current shell.

14. Ans : B

Explanation: The shell has two prompts (PS1 and PS2).

15. Ans : C

Explanation: We cannot use the unset command to unset variables that are
marked readonly.

16. Ans : A

Explanation: env is an external command which runs in a child process and


it lists only environment variables which are inherited from its parent, the
shell.

17. Ans : A

Explanation: $# : The number of arguments supplied to a script.

18. Ans : C

Explanation: character operator is not in the Bourne shell, instead of the


character operator, there is an operator called a string operator.

19. Ans : C
Explanation: The complete expression should be enclosed between , called
the backtick.

20. Ans : C

Explanation: -ge keyword is used to represent greater than or equal.

21. Ans : D

Explanation: All the above operators are supported by the Bourne Shell.

22. Ans : D

Explanation: The foreach loop is not available in shell.

23. Ans : B

Explanation: The while loop executes the given commands until the given
condition remains true.

24. Ans : C

Explanation: Break and continue two statements that are used to control
shell loops.

25. Ans : B

Explanation: A loop may continue forever if the required condition is not


met is known as infinite loop.

26. Ans : D

Explanation: The break statement is used to terminate the execution of the


entire loop.

27. Ans : D

Explanation: Unix Shell supports case...esac statement.


28. Ans : D

Explanation: continue is used to skip the statments and can not be used with
case...esac.

29. Ans : A

Explanation: The continue statement is similar to the break command,


except that it causes the current iteration of the loop to exit, rather than the
entire loop.

30. Ans : A

Explanation: Continue is the syntax used forcontinue statement.

You might also like