If you are wondering what $$ (double-dollar) is in a bash shell script, well it is a special variable that can be used to know the Process ID or PID of the current shell.
Let's try running this on a bash shell.
bash_script.sh#!/bin/bash
echo "The process ID of the current shell is: $$"
Result:
./bash_script.sh
The process ID of the current shell is: 4181
List of Special Variable that starts with $ and their meaning
| Character | Description |
|---|---|
$ | Variable expansion |
$! | Process ID of the most recent background command |
$$ | Process ID of the current shell |
$? | Exit status of the most recently executed command |
$# | Number of command-line arguments passed to the script |
$* | All command-line arguments as a single string (positional parameters) |
$@ | All command-line arguments as separate strings (positional parameters) |
$0 | Name of the script itself (or the shell) |
$1, $2, $3, ... | Individual command-line arguments (positional parameters) |

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!