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
2009-12-04 13:02:49
which process id, ksh itself, parent or child?
Sachin Chourasiya
2009-12-04 13:07:05
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
2009-12-04 13:34:58
@Philip: huh? surely you mean ". ./script" then it executes in the current shell
glenn jackman
2009-12-04 14:51:20
Yep - I ment $ . ./script - Can you edit and correct comments?
Philip Schlump
2009-12-04 17:40:11
+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
2009-12-04 13:26:26