If I have the script "script1.sh" and I want to make it print its own PID as a first step. How can I do this in bash?
1 Answer
The PID of the currently running script is $$
2(
$$) Expands to the process ID of the shell. In a()subshell, it expands to the process ID of the invoking shell, not the subshell.