Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does #$ do in bash? (aka: Hash dollar sign, pound dollar sign)

Tags:

bash

shell

I came across this expression in a bash script and it's really not easy to google for.

#$... 

Thanks for your help!

like image 548
CAN Avatar asked Mar 09 '12 07:03

CAN


People also ask

What does the fox say Meaning?

Speaking of the meaning of the song, Vegard characterizes it as coming from "a genuine wonder of what the fox says, because we didn't know". Although interpreted by some commentators as a reference to the furry fandom, the brothers have stated they did not know about its existence when producing "The Fox".

What does a real fox say?

One of the most common fox vocalizations is a raspy bark. Scientists believe foxes use this barking sound to identify themselves and communicate with other foxes. Another eerie fox vocalization is a type of high-pitched howl that's almost like a scream.

How can I find a song by the sound?

On your phone, touch and hold the Home button or say "Hey Google." Ask "What's this song?" Play a song or hum, whistle, or sing the melody of a song. Hum, whistle, or sing: Google Assistant will identify potential matches for the song.


2 Answers

#$ does "nothing", as # is starting comment and everything behind it on the same line is ignored (with the notable exception of the "shebang").

$#, as you had it, prints the number of arguments passed to a shell script (like $* prints all arguments).

like image 173
Christian.K Avatar answered Sep 20 '22 16:09

Christian.K


In bash this is generally a comment, everything after the hash (on the same line) is ignored. However, if your bash script is being passed to something unusual it could be interpreted by that.

For instance, if you submit a script to the Sun Grid Engine: "Any line beginning with hash-dollar, i.e., #$, is a special comment which is understood by SGE to specify something about how or where the job is run. In this case we specify the directory in which the job is to be run (#$ -cwd) and the queue which the job will join (#$ -q serial.q)." (source: http://talby.rcs.manchester.ac.uk/~rcs/_linux_and_hpc_lib/sge_intro.html)

like image 34
user1439517 Avatar answered Sep 20 '22 16:09

user1439517