From the course: Linux Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Bash operators

Bash operators - Linux Tutorial

From the course: Linux Tips

Bash operators

- [Instructor] When we're working with Bash scripts, it's important to be able to use numbers and comparisons in our work. Does the storage array have more than 30 terabytes free or less? Does the configuration file exist? Has that process been running for less than a minute? Arithmetic and comparison operators help us answer these questions. Let's take a look at arithmetic operators first. Bash supports common arithmetic operators like addition, subtraction, multiplication, and division. And it also supports exponentiation and modulo operators as well. Let's use arithmetic expansion here at the command line. To do that, I'll write echo and then a $ and two opening parentheses. Let's add 5+4 and follow that up with two closing parentheses. I see the result of nine, alright. Now let's subtract, I'll write echo $ opening parentheses 5-4. Good so far, now let's multiply. Okay, and division. I'll write 5/4 and, well, what's going on here? That should be one and a quarter. One thing to…

Contents