Atlas91
Atlas91

Reputation: 5904

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 $.

Upvotes: 4

Views: 4322

Answers (1)

chepner
chepner

Reputation: 532398

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.

Upvotes: 6

Related Questions