Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What does the output of the command below mean? (result is positive integer)

echo $$
share|improve this question
1… is related – kojiro Jan 20 '13 at 21:14
up vote 15 down vote accepted

The $$ variable in bash and other shells contains the process id of the shell.

See this Stack overflow question and this one also has more detail about what it is more precisely, and commands similar to it.

share|improve this answer
+1. Documented in the bash manual – glenn jackman Jan 20 '13 at 19:02

As the other (accepted) answer indicated, the $ param represents the current process id (PID) of the current shell.

Echoing this param should work in most shells (not just Bash):


$ echo $0
$ echo $$


$ echo $0
$ echo $$


% echo $shell
% echo $$

It's important to note too, that commands from within the shell will run under the shell's parent process id (PPID).

$ echo $$
$ ps -ef | grep 6780
aploetz   6780  6770  0 11:15 pts/2    00:00:00 bash
aploetz   8572  6780  0 11:34 pts/2    00:00:00 ps -ef
aploetz   8573  6780  0 11:34 pts/2    00:00:00 grep --color=auto 6780
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.