is $$ a variable of some sort? it seems to contain a value..
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
just a curiosity..
Is a double-dollarsign actually a variable? If so/not then what is the value being returned by it as seen above? A different value for Sasha than for root, too.
How I noticed this:
I was reading the kernel Makefile, and came across this little section:
Code:
help:
@echo ' Building external modules.'
@echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
@echo ''
@echo ' modules - default target, build the module(s)'
@echo ' modules_install - install the module'
@echo ' clean - remove generated files in module directory only'
@echo ''
.. and there, the second @echo line has M=$$PWD target which I thought might be a typo, so I tried the echo command as seen in the first [code] tags above.
I tried running `make help` to see what got printed, but the above help: section did not get printed to the console.
Sasha
UPDATE: The value returned by $$ is the PID of the bash console in use! However, it still seems like a typo in the Makefile (unless make interprets it differently) because "${bashPID}${PWD}" doesn't seem really useful, to me anyhow.
Last edited by GrapefruiTgirl; 06-09-2008 at 07:38 AM.
Reason: Discovered something..
$$ is the PID of the script's current running process. I'm willing to bet if you issue another $$ and then "ps -ef | grep -i bash", you will find a Bash process with the number returned by $$.
$$ wouldn't return the same number if you wrote a script with "echo $$" in it, as a new process is spawned to execute a script. Then again, this is all theoretical, as I don't have a Linux (or UNIX) machine within reach, right now.
Yes, for the test with "echo $$" the meaning of the double dollar is that explained in the previous posts, but in a Makefile you have to put a double $$ to retrieve the value of a shell variable. The $$PWD is replaced by the value of the PWD variable. The single dollar sign in Makefiles is meant to call a macro.
$$ is the PID of the script's current running process. I'm willing to bet if you issue another $$ and then "ps -ef | grep -i bash", you will find a Bash process with the number returned by $$.
$$ wouldn't return the same number if you wrote a script with "echo $$" in it, as a new process is spawned to execute a script. Then again, this is all theoretical, as I don't have a Linux (or UNIX) machine within reach, right now.
Yes, for the test with "echo $$" the meaning of the double dollar is that explained in the previous posts, but in a Makefile you have to put a double $$ to retrieve the value of a shell variable. The $$PWD is replaced by the value of the PWD variable. The single dollar sign in Makefiles is meant to call a macro.
__________________
Theory is when you know all and nothing works. Practice is when all works and nobody knows why. In this case we have put together theory and practice: nothing works... and nobody knows why! (Albert Einstein)
Thanks to you both for the excellent answers; I did try googling the $$ but nothing specific turned up on the first pages or so. I didn't go too mad over it as it was more a curiousity than anything, but I have learned something once again today, from each of you.
PS - Colucix, I do like that Einstein quote in your signature
PPS -
Quote:
Originally Posted by indienick
...as I don't have a Linux (or UNIX) machine within reach, right now.
-- I'm sorry to hear that, you must feel uncomfortable I would! Heh heh, well I hope you are not in a room with a lot of windows.
Cheers!
sasha
Last edited by GrapefruiTgirl; 06-09-2008 at 08:21 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.