Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's the process id of the bash process itself.</p> <p>You might use it to track your process over its life - use <a href="http://linux.die.net/man/1/ps" rel="noreferrer"><code>ps -p</code></a> to see if it's still running, send it a signal using <code>kill</code> (to pause the process for example), change its priority with <code>renice</code>, and so on.</p> <p>Process ids are often written to log files, especially when multiple instances of a script run at once, to help track performance or diagnose problems.</p> <p>Here's <a href="http://www.gnu.org/software/bash/manual/bashref.html#Special-Parameters" rel="noreferrer">the bash documentation</a> outlining special parameters.</p> <p><a href="http://www.gnu.org/software/bash/manual/bashref.html#Bash-Variables" rel="noreferrer"><code>BASHPID</code></a>, mentioned by ghostdog74, was added at version 4.0. Here's an example from Mendel Cooper's <em><a href="http://tldp.org/LDP/abs/abs-guide.pdf" rel="noreferrer">Advanced Bash-Scripting Guide</a></em> that shows the difference between <code>$$</code> and <code>$BASHPID</code>:</p> <pre><code>#!/bin/bash4 echo "\$\$ outside of subshell = $$" # 9602 echo "\$BASH_SUBSHELL outside of subshell = $BASH_SUBSHELL" # 0 echo "\$BASHPID outside of subshell = $BASHPID" # 9602 echo ( echo "\$\$ inside of subshell = $$" # 9602 echo "\$BASH_SUBSHELL inside of subshell = $BASH_SUBSHELL" # 1 echo "\$BASHPID inside of subshell = $BASHPID" ) # 9603 # Note that $$ returns PID of parent process. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload