Match the following with reference to Unix shell scripts : List I List II a.…

2014

Match the following with reference to Unix shell scripts :

List I List II
a. $? i. File name of the current script
b. $# ii. List of arguments
c. $0 iii. The Number of arguments
d. $* iv. Exit status of last command

Codes :

  1. A.

    a-iii, b-ii, c-i, d-iv

  2. B.

    a-ii, b-iii, c-i, d-iv

  3. C.

    a-iv, b-iii, c-i, d-ii

  4. D.

    a-i, b-iii, c-i, d-iv

Attempted by 39 students.

Show answer & explanation

Correct answer: C

Correct match:

  • $? — Exit status of the last command (0 indicates success).

  • $# — The number of positional arguments passed to the script.

  • $0 — File name of the current script (the command used to invoke the script).

  • $* — The list of positional arguments as a single word (all arguments).

Therefore the correct matching is: a → $? (exit status), b → $# (number of arguments), c → $0 (script file name), d → $* (list of arguments).

Tip: Use these variables in scripts to check command success with $? or to process command-line arguments with $# and $*.

Explore the full course: Nta Ugc Net Paper 2

Loading lesson…