Tsallaka zuwa abun ciki
Justice Tech School

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

Are spaces allowed around = in an assignment?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.