Variables in Bash
Variables store data that you can use later in your script.
Rules of Variables
- NO SPACES around the equals sign!
- Correct:
NAME="Alice" - Incorrect:
NAME = "Alice"
- Correct:
- Reference variables using the
$symbol.
#!/bin/bash
USER_NAME="Student"
echo "Welcome, $USER_NAME!"
Environmental Variables
You can export a variable to make it available to child processes (like other scripts or programs you run from this script).
export APP_ENV="production"
booting...