![What does mean $$ or $! in bash? [closed]](https://www.xszz.org/skin/wt/rpic/t13.jpg)
Question:
It's kind of easy question but I didn't find any information. What does mean $!
or $$
in bash?
For example: ps -p $!
or pstree $$
?
Actually, these variables were inherited by bash from the Bourne shell.
"$$" means current PID.
"$!" is the PID of the last program your shell ran in the background (e.g. "myprog &")
Here is a list of shell variables:
<ul><li><a href="http://unixhelp.ed.ac.uk/scrpt/scrpt2.2.2.html" rel="nofollow">http://unixhelp.ed.ac.uk/scrpt/scrpt2.2.2.html</a></li> </ul>Answer2:<a href="http://tldp.org/LDP/abs/html/internalvariables.html#PIDVARREF" rel="nofollow">$!
</a> is the process ID of the last job run in the background.
<a href="http://tldp.org/LDP/abs/html/special-chars.html#PROCESSIDREF" rel="nofollow">$$
</a> is the process ID of the script itself.
(Both of the above are links to the <a href="http://tldp.org/LDP/abs/html/" rel="nofollow">Advanced Bash Scripting Guide</a> on TDLP.)