special-parameter

Bash $$ — invoking shell process ID

Expands to the process ID of the invoked shell. In a parenthesized subshell it retains the invoking shell PID. Compare BASHPID for the current Bash process.

Formal Syntax & Structure

bash syntaxbash
$$

Return Value

integer text

Invoking shell process identifier.

Working Example

Example Snippetbash
printf 'outer: %s %s\n' "$$" "$BASHPID"( printf 'inner: %s %s\n' "$$" "$BASHPID" )
Bash Reference