The Bash Scripting Tutorial, Part 2

Using variables and conditionals in Bash

Vickie Li
The Startup

--

Photo by Dominik Scythe on Unsplash

If you work with computers, there’s probably been a time where you’ve thought: “Wow, there’s got to be a way I can automate this”.

A computer script is a list of commands designed to be executed by a program. They are used to automate tasks such as data analysis, webpage generation, and system administration. And the ability to understand and create scripts is one of the most sought after skills in the IT world.

Last time, we talked about bash scripts, what they are, and why you should use them. You even wrote a simple bash script of your own!

Today, let’s dive deeper into bash scripts. You will learn how to use variables and conditionals with bash, and how you can use them to build scripts that do more.

Setting up

For this tutorial, let’s build a program that calculates the user’s current age in days. The program takes the user’s birthdate as input and outputs the user’s age in days as of today.

--

--

Vickie Li
The Startup

Professional investigator of nerdy stuff. Hacks and secures. Creates god awful infographics. https://twitter.com/vickieli7