From a6eac57a596fff11b0fd556ef3f5c5f8a43abff9 Mon Sep 17 00:00:00 2001 From: jworthy Date: Tue, 23 Oct 2018 21:57:12 -0400 Subject: [PATCH] Added documentation for in scripting folder --- _commands/scripting/$variable.md | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 _commands/scripting/$variable.md diff --git a/_commands/scripting/$variable.md b/_commands/scripting/$variable.md new file mode 100644 index 000000000..ddcf42c60 --- /dev/null +++ b/_commands/scripting/$variable.md @@ -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) +~~~ + + + +### 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'.