课程: Linux Tips

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Bash operators

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…

内容