Skip to content
This repository was archived by the owner on Jun 2, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions _commands/scripting/$variable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
---

$ (Dollar sign prefix to a variable)
-------

'$variable'
The prefix '$' lets the shell interpret 'variable' as a variable.

~~~ bash
$ echo $PATH
/home/username/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)
~~~

<!--more-->

### Useful Options / Examples

#### 'MY_VAR="10"; echo $MY_VAR'
~~~ bash
$ MY_VAR=10; echo $MY_VAR
10
~~~


##### Break it down
* MY_VAR has value 10, and '$' must be used to print this value.

#### 'EXEC="./correct.out"; $EXEC'
~~~bash
$ EXEC="./correct.out"; $EXEC
correct output
~~~

##### Break it down

* The terminal replaces the $EXEC with its value, and reads it as if it was typed by the user. Therefore, the terminal runs the executable 'correct.out'.