Commands are separated by whitespace, but sometimes you need literal spaces in arguments:
# Problem: This creates multiple files
touch my file.txt
# Creates: "my" and "file.txt"
# Solutions:
touch "my file.txt" # Double quotes
touch 'my file.txt' # Single quotes
touch my\ file.txt # Backslash escape
touch "my file.txt" # Preferred method
NAME="Linux"
echo 'Hello $NAME' # Output: Hello $NAME
echo 'The cost is $5' # Output: The cost is $5
echo 'Today is $(date)' # Output: Today is $(date)
NAME="Linux"
echo "Hello $NAME" # Output: Hello Linux
echo "The cost is \$5" # Output: The cost is $5
echo "Today is $(date)" # Output: Today is Mon Jan 1 12:00:00 UTC 2024
# Working with filenames containing spaces
ls "Program Files"
cd "My Documents"
cp "old file.txt" "new file.txt"
# Combining quotes
echo "User's home directory: $HOME"
echo 'Use "double quotes" for variables'
# Mixed content
MESSAGE="Hello"
echo "$MESSAGE 'World' from Linux"
Next: → Special Characters And Echo
Previous: ← Learning Objectives
Lesson Home: ↑ Lesson 5: Echo, Alias & Operators
Course Home: ⌂ Introduction to Linux