Skip to content

Bash Variables & Quoting

Quoting controls how Bash expands variables and splits words. Prefer "$var".

Example

#!/bin/bash
name="Chris App"
echo Hello $name
echo "Hello $name"
echo 'Hello $name'
today=$(date +%F)
echo "Today is $today"

How to run it

  1. Save it to a file.
  2. Run chmod +x filename.sh where applicable.
  3. Run it from the terminal.

← Back homeRun in Sandbox →