What does the $$ mean?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
leetow2003
Member
Member
Posts: 70
Joined: Fri Nov 19, 2010 6:54 pm

What does the $$ mean?

Post by leetow2003 »

I read a Makefile,look:

Code: Select all

dep:
	(for i in init/*.c;do echo -n "init/";gcc -M $$i;done) >> tmp_make
	cp tmp_make Makefile

if I write a shell script using the same codes,I find the $$i must be replaced
by $i,why?I want to know what the $$ means?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: What does the $$ mean?

Post by Combuster »

What does $ mean to make?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: What does the $$ mean?

Post by iansjack »

In this instance, do you want the command interpreter to see the value of $i, or do you want it to see "$i"?
kohlrak
Posts: 18
Joined: Mon Mar 04, 2013 1:54 am

Re: What does the $$ mean?

Post by kohlrak »

leetow2003 wrote:I read a Makefile,look:

Code: Select all

dep:
	(for i in init/*.c;do echo -n "init/";gcc -M $$i;done) >> tmp_make
	cp tmp_make Makefile

if I write a shell script using the same codes,I find the $$i must be replaced
by $i,why?I want to know what the $$ means?
I'm not 100% sure, but it could be that $$ is a makefile escape for $, while in shells $$ represents the process ID.
Post Reply