$$ gives process id of the script process when used in a script, like this:
$$
Example 1
#!/bin/bash # processid.sh # print process ids ps
The replacement takes place in the parent shell; the subshell hasn't been started by the time the substitution takes place.