Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am actually playing with arguments and its happened. I just thought like to see what will happen if I type $$1 and I did it and got something below.

raja@raja-BONEFISH:~$ $$1
19301: command not found

What's that 19301 mean, is it telling something?

Bottom-Line: what does meaning for $$1 in bash.

share|improve this question
1  
ouch!! that much easy thing. I am still have many things to learn. All answers are super. +1 to all. –  Raja May 20 at 17:55

4 Answers 4

up vote 24 down vote accepted

$$ is the PID (process id) of the current process.

$$1 is the above PID followed by the literal string 1.

So it is telling you that your bash is the process with PID 1930.

But... free trick:

show() { eval echo \$$1; }
show PATH
/home/romano/bin:/usr/local/bin:/bin:/usr/bin

(quite convoluted, ain't it?)

More info in TLDP.

share|improve this answer
1  
1  
For a moment I read the TLDP as "Too Long Didn't Pee". –  Luis Alvarado May 27 at 0:07
  • $$ - pid of the current shell (not subshell) - see What are the special dollar sign shell variables?

  • $$1 - pid of the current shell (not subshell) followed by 1.

  • $$2 - pid of the current shell (not subshell) followed by 2.

  • $$a - pid of the current shell (not subshell) followed by a character.

  • And so on...

See the output of echo $$1.

And you get the error command not found because you are trying to execute a string composed of digits which obviously is not a command.

share|improve this answer

You have concatenated $$ and 1 together to get the PID of the current shell and 1, i.e. $$ stands for the PID of the currently running shell and 1 is just a character, you could do $$a, $$@ to get the PID concatenated with the following character.

share|improve this answer

$$ it will state 1930 which is pid of current shell .

When you type $$1 that means pid followed by one so you the output would be 19301 .

Try $$2 the output will be 19302

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.