$$

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to navigation Jump to search

The word '$$' may refer to:

$$ as PID

$$ expands to the process ID (PID) of the shell. To see your bash PID, enter:

echo $$
echo "My shell PID: $$"
ps

Sample outputs:

3654
My shell PID: 3654
  PID TTY          TIME CMD
 3654 pts/2    00:00:00 bash
 4715 pts/2    00:00:00 ps

In above example 3654 is my bash shell pid.

$$ in subshell

In a () subshell, it expands to the process ID of the current shell, not the subshell.