what does the $$ do?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting what does the $$ do?
# 1  
Old 09-28-2006
what does the $$ do?

Could anyone please help me out with understanding what thhe following bit does:

A = ${B}.{C}.$$

and later on in the script

java abc ${A}

WHat does A equal to?

Thanks so much
V
# 2  
Old 09-28-2006
$$ is the pid of the process.

Example:

ncpr1 $ ps
PID TTY TIME CMD
12415 pts/17 0:00 ksh
16571 pts/17 0:00 ps

ncpr1 $ touch junkfile.$$

ncpr1 $ ls -l junkfile.12415
-rw-r--r-- 1 mark king 0 Sep 28 12:25 junkfile.12415
ncpr1 $
# 3  
Old 09-28-2006
$$ is often use to constitute temporary file names.

In your case, the value of variable A will change with each execution.
Two processes executing the script simultaneously will work with a different value for A.

Jean-Pierre.
# 4  
Old 09-28-2006
$$ makes it unique - by using the PID of the process
eg
echo "test" > outfile$$ will create an outfile[PID]
Login or Register to Ask a Question

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