Variables
Assign with name=value and no spaces around =. Read with $name or ${name}. Quote variables to protect spaces. $(command) captures command output.
Example
name="Ada"
age=21
echo "Name: $name, age: ${age}"
today=$(echo "captured")
echo "Got: $today"
readonly PI=3.14
echo $PI
echo "length: ${#name}"
echo "${name^^}"Result
Name: Ada, age: 21 Got: captured 3.14 length: 3 ADA
Exercise
Read a variable.
echo name
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.