When I use these shell commands:
[root@linux /tmp]# a=$$ [root@linux /tmp]# echo $a 3985
where does the value 3985 come from? And why?
That's why some people use it to construct a filename that's only used temporarily and then destroyed, as in this script fragment.
As mentioned above, the $$ in the filename will be the PID of the main script.