What is $$


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What is $$
# 1  
Old 04-08-2008
What is $$

Hi,
In a shell script i have seen the following statement.
TEMPSQL=/tmp/sample-$$.sql
Here whats the purpose of $$ in sample-$$.sql.

cheers
RRK
# 2  
Old 04-08-2008
Quote:
Originally Posted by ravi raj kumar
Hi,
In a shell script i have seen the following statement.
TEMPSQL=/tmp/sample-$$.sql
Here whats the purpose of $$ in sample-$$.sql.

cheers
RRK
See man sh under the section Special Parameters

Code:
       $      Expands  to  the process ID of the shell.  In a () subshell, it
              expands to the process ID of the current shell,  not  the  sub-
              shell.

# 3  
Old 04-08-2008
a good example:

Code:
$ ps -ax | grep bash | grep -v grep
  344  p1  Ss     0:00.09 -bash

$ echo $$
344

it's the same pid (process id).
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question