这是一个简单的问题,但我没有找到任何信息。是什么意思$!或$$在bash?
例如:ps -p $! 或pstree $$?
实际上,这些变量是 bash 从 Bourne shell 继承的。
$$表示当前 PID。
$!是您的 shell 在后台运行的最后一个程序的 PID(例如myprog &)
这是一个shell变量列表:
$! is the process ID of the last job run in the background.
$$ is the process ID of the script itself.
(Both of the above are links to the Advanced Bash Scripting Guide on TDLP.)