shell 脚本 $$ 值

klo*_*lod 1 scripting shell

当我使用这些 shell 命令时:

[root@linux /tmp]# a=$$
[root@linux /tmp]# echo $a
3985
Run Code Online (Sandbox Code Playgroud)

值 3985 来自哪里?为什么?

sym*_*ean 10

man bash
Run Code Online (Sandbox Code Playgroud)

解释它。

Expands to the process ID of the shell.  In a () subshell, 
it expands to the  process ID of the current shell, not the subshell.
Run Code Online (Sandbox Code Playgroud)