$$ in a script vs $$ in a subshell

前端 未结 4 1806
既然无缘
既然无缘 2020-12-01 21:43

$$ gives process id of the script process when used in a script, like this:

Example 1

#!/bin/bash
# processid.sh
# print process ids

ps         


        
4条回答
  •  难免孤独
    2020-12-01 22:11

    The replacement takes place in the parent shell; the subshell hasn't been started by the time the substitution takes place.

提交回复
热议问题