MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

UNIX

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The first argument is read by the shell into the parameter ____
A
1$
B
$3
C
$$
D
$1
Explanation: 

Detailed explanation-1: -Explanation: Command line arguments are stored into positional parameters. The first argument is read by the shell into the parameter $1, second argument in $2 and so on.

Detailed explanation-2: -We also have $ and $* as wildcard characters which are used to denote all the arguments. We use $$ to find the process ID of the current shell script, while $? can be used to print the exit code for our script.

Detailed explanation-3: -Arguments passed to a script are processed in the same order in which they’re sent. The indexing of the arguments starts at one, and the first argument can be accessed inside the script using $1. Similarly, the second argument can be accessed using $2, and so on.

Detailed explanation-4: -$?-It gives the value stored in the variable “?". Some similar special parameters in BASH are 1, 2, *, # ( Normally seen in echo command as $1, $2, $*, $#, etc., ) . Follow this answer to receive notifications. edited Jun 20, 2020 at 9:12. CommunityBot.

There is 1 question to complete.