All Modules / Module 6 / Lesson 1 of 4

Why long commands cause mistakes

3 minute read

Module 6

Reducing Mental Load With Variables and Aliases

Long commands are error-prone. The more you have to remember and type correctly, the more likely you are to make a mistake. In this module, you'll learn to use variables and aliases to lock down the parts that don't change, so you only think about what matters. Your commands will become simpler, clearer, and more reliable.

Give Things Names

A variable is just a name you give to a value. Instead of typing the same long thing over and over, you give it a short name.

For example, instead of typing /Users/yourname/Documents/Projects/Website every time, you could call it $work.

Create a Variable

1

Create a variable (no spaces around the =):

myname="Your Name"
2

Use it by putting $ in front:

echo "Hello, $myname"

Terminal replaces $myname with whatever value you assigned.

Key Takeaway

Variables store values. Create with name=value, use with $name.