$$  –  Shell Process ID

$$ expands to the process ID of the invoked shell. In a subshell it expands to the same ID as that of the parent process.

Examples

Print PID of the main shell twice
1
2
3
4
# main
echo "$$"
# subshell
(echo "$$")
Output:
1
2
140352
140352
BashSupport Pro 是一款 Bash 和 POSIX 集成开发环境,支持 $$ - 立即试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款