How does a Linux/Unix Bash script know its own PID?

Debugger picture Debugger · Mar 22, 2010 · Viewed 142.5k times · Source

I have a script in Bash called Script.sh, and it needs to know its own PID (i.e. I need to get PID inside the Script.sh )

Any idea how to do this ?

Answer

Paul Tomblin picture Paul Tomblin · Mar 22, 2010

The variable '$$' contains the PID.