Find the PID of the current Bash script


In many cases you will need to determine the PID of a current Bash script or shell. Bash stores a specific variable that allows you to view the process ID of the current shell “$$‘.

You can echo the $$ to print the current PID.
$ echo $$23490