“$$” is a useful Linux variable you could use in your script to get
it’s PID. The “$$” variable always holds the PID of the executing
process.
Why do you need it? Maybe to check if the script is already running? This is what I normally use it for.
Sample Script; #!/bin/bash
echo "My PID is $$"
sleep 2
Sample Output; [root@keke ~]# ./test1.sh
My PID is 8909