What is the meaning of $$1 in bash?
Solution 1:
$$
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.
Solution 2:
$$
- 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 by1
.$$2
- pid of the current shell (not subshell) followed by2
.$$a
- pid of the current shell (not subshell) followed bya
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.
Solution 3:
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.