tags:

views:

99

answers:

2
+3  Q: 

$$ in ksh shell

Please tell me the meaning of $$ in ksh shell? I guess it is associated with the process id but I want to know its exact meaning.

A: 

It is used for making temporary names with the process id. Say you need a file name but that name needs to be unique to the process you are in - so if more than one person runs the same ksh script they will not step on each other.

$$ is in bash, sh and other UN*X shells.

Philip Schlump
which process id, ksh itself, parent or child?
Sachin Chourasiya
If you run a ksh script then ksh forks and the child runs as it's own process. If you run something with "$ ./script" then it runs inline in the current process.
Philip Schlump
@Philip: huh? surely you mean ". ./script" then it executes in the current shell
glenn jackman
Yep - I ment $ . ./script - Can you edit and correct comments?
Philip Schlump
+4  A: 

$$ is the process id of the ksh process itself; $PPID is the process id of its parent.

Here's the ksh (93) documentation for special parameters (it's after the fold). Same info for ksh88.

martin clayton
Thanks Martin, I got my answer :)
Sachin Chourasiya