$$
is the current script's pid$!
is the pid of the last background processHere's a sample transcript from a bash session (%1
refers to the ordinal number of background process as seen from jobs
):
$ echo $$
3748
$ sleep 100 &
[1] 192
$ echo $!
192
$ kill %1
[1]+ Terminated sleep 100