When the command echo $$ outputs 12942, what is the meaning of 12942?

When the command echo $$ outputs 12942, what is the meaning of 12942?
A . It is the process ID of the echo command.
B . It is the process ID of the current shell.
C . It is the process ID of the last command executed.
D . It is the process ID of the last command which has been placed in the background.

Answer: B

Explanation:

In bash, the PID of a shell script’s subshell process is stored in a special variable called $$. This variable is read-only, and you cannot modify it in a shell script1. You can use echo $$ to get the PID of the current bash shell you are using2. Therefore, when the command echo $$ outputs 12942, it means that the PID of the current shell is 12942.

Reference: [LPI Linux Essentials – Topic 103: Command Line Basics]

[Bash Special Parameters]

How to get the process ID (PID) of a shell script

How to know the process id of current bash session?

Latest 102-500 Dumps Valid Version with 194 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments