From the course: Linux: Bash Shell and Scripts

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using arithmetic operators

Using arithmetic operators - Linux Tutorial

From the course: Linux: Bash Shell and Scripts

Start my 1-month free trial

Using arithmetic operators

- Bash has a wealth of arithmetic operators and you can conveniently use them with the double parenthesis or the let command. You can increment a variable with ++, decrement with --, you can either do the post or the pre increment or decrement. We've got not and exponentiation and shifting and less than or equal to and And and equal. We've got the expression question marks, expression colon, expression, kind of, if then out sort of thing, if the first expression is true then the value is the second expression but the first expression is false then the value is the third expression. We've got different kinds of assignment, X, operator equal means X equals X operator and then the value, so, X* equals 5 would be X equals X times 5. And the comma operator means do the first thing and then do the second thing and the value of the expression is the value of the second expression. A couple of simple examples, we assign N is 5 and then we just increment N, so now N will be 6. And we see…

Contents