$$ and $#: what do they mean


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers $$ and $#: what do they mean
# 1  
Old 08-14-2011
Data $$ and $#: what do they mean

Hi,

I need to know what the below variables are used for in UNIX.
1.$$
2.$#
i am a newbie in UNIX and need to debug some shell scripts where i have spotted these. I am aware about the $? which gives the exit code of the last executed command but not the above two.

Regards,
Debo
# 2  
Old 08-14-2011
See here - Man Page for sh (OpenSolaris Section 1) - The UNIX and Linux Forums for parameters "$" and "#". They are names for variables "$$" and "$#".
# 3  
Old 08-14-2011
Thanks for the link, however it's still not clear what actually these variables represent.Smilie
# 4  
Old 08-14-2011
Code:
% echo $$
32558

% ps
  PID TTY          TIME CMD
32558 pts/0    00:00:00 zsh
32642 pts/0    00:00:00 ps

% cat >script
echo $#

% sh script a b c d
4

% sh script xxx 'yyy zzz'
2

This User Gave Thanks to yazu For This Post:
# 5  
Old 08-14-2011
Wow..that was great. $$ is the PID of the shell and $# is the number of arguments to a shell script..excellent..thanks a lot. Smilie
 
Login or Register to Ask a Question

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