Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the $ in bash?

I've been using bash for about 3 mounth.
I'm understanding the language step by step but I have a question.
The real significate of $ in bash is the same of C?

I mean the $ not $1, $0, $# etc etc.
Only the $.

like image 725
Atlas91 Avatar asked Sep 06 '25 03:09

Atlas91


1 Answers

The $ is used to perform parameter expansion. For a variable named foo, the expression $foo expands to the value of the variable.

$ foo=3
$ echo "foo"
foo
$ echo "$foo"
3

$ is also used as the default/generic prompt, but there it is simply used as a distinctive character; it has no actual meaning, and could be replaced without causing any change in functionality.

like image 139
chepner Avatar answered Sep 07 '25 21:09

chepner