What Does "$$" Mean in Shell?

Find out what $$ (double dollar sign) means in shell

In a shell, $$ refers to the process id (PID) of the current running process. For example, when used inside a shell script, it would return the process id of the running script. Similarly, when used inside a terminal (e.g. echo $$), it would return the process id of the current shell (as the current running process in that case would be the shell itself). One common use of $$ is to check which shell is being used in terminal.

Using $$ is not considered a good way to generate unique filenames, and should be avoided for such tasks wherever possible because it can lead to vulnerabilities in your shell scripts.


Hope you found this post useful. It was published . Please show your love and support by sharing this post.