$$ 或 $! 是什么意思?在 bash 中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/13671750/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does mean $$ or $! in bash?
提问by NGix
It's kind of easy question but I didn't find any information. What does mean $!or $$in bash?
这是一个简单的问题,但我没有找到任何信息。这是什么平均值$!或$$在bash?
For example: ps -p $!or pstree $$?
例如:ps -p $!或pstree $$?
回答by paulsm4
Actually, these variables were inherited by bash from the Bourne shell.
实际上,这些变量是由 bash 从 Bourne shell 继承的。
"$$" means current PID.
“$$”表示当前PID。
"$!" is the PID of the last program your shell ran in the background (e.g. "myprog &")
“$!” 是您的 shell 在后台运行的最后一个程序的 PID(例如“myprog &”)
Here is a list of shell variables:
下面是一个 shell 变量列表:
回答by T.J. Crowder
$!is the process ID of the last job run in the background.
$!是在后台运行的最后一个作业的进程 ID。
$$is the process ID of the script itself.
$$是脚本本身的进程 ID。
(Both of the above are links to the Advanced Bash Scripting Guideon TDLP.)
(以上两个都是指向TDLP 上的高级 Bash 脚本指南的链接。)

