Just Enough CLI · Step 6 Free
Variables, PATH, and special characters
Every broken tool installation ends with someone saying “check your PATH”. This topic makes that sentence make sense.
Shell variables
The shell stores temporary text values in shell variables. Assign with = (no spaces!) and read with $:
HOST=127.0.0.1
echo $HOST
Environment variables
An environment variable is like a shell variable, with one key difference: the operating system passes environment variables to every program the shell runs. Shell variables stay inside the shell.
Promote a shell variable with export:
STUFF=blah
export STUFF
This matters daily in data work: AWS_PROFILE, DBT_PROFILES_DIR, DATABASE_URL — tools read their settings from environment variables. Putting export lines into ~/.zshrc makes them permanent.
PATH — how the shell finds commands
PATH is a special environment variable holding a list of directories the shell searches when you type a command:
echo $PATH
/usr/local/bin:/usr/bin:/bin
When you type python, the shell walks these directories in order and runs the first python it finds. “Command not found” means the program’s directory is not in PATH. Two commands you will use when debugging installs:
which python # which file actually runs
echo $PATH # what the shell searches
Special characters
Learn to read these fluently — they appear in every script and Stack Overflow answer:
| Symbol | Name | Meaning |
|---|---|---|
* | star | wildcard / regex repeat |
. | dot | current directory; one char in regex |
! | bang | negation, command history |
| | pipe | connect commands |
/ | slash | directory separator |
\ | backslash | escape the next character |
$ | dollar | read a variable |
' | single quote | literal string (nothing expands) |
" | double quote | string where $vars still expand |
^ | caret | start of line (regex) |
~ | tilde | home directory |
# | hash | comment |
[ ] | brackets | character ranges |
{ } | braces | blocks, ranges |
_ | underscore | space substitute in names |
The quoting difference is worth remembering: echo '$HOST' prints $HOST literally; echo "$HOST" prints the value.
Practice in your terminal:
- Create a variable:
NAME=yourname, thenecho $NAME. - Run
echo $PATHand count the directories (they are separated by:). - Run
which gitandwhich python— see where they live. - Compare
echo '$NAME'andecho "$NAME".