What does mean $$ or $! in bash? [closed]

2019-07-16 05:35发布

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 $$?

标签: bash shell
2条回答
SAY GOODBYE
2楼-- · 2019-07-16 05:50

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:

查看更多
放我归山
3楼-- · 2019-07-16 06:06

$! 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.)

查看更多
登录 后发表回答