ScriptingLesson 48Free preview
Bash Operators
This lesson is part of Bash · All levels
Summary
Bash operators include arithmetic operators, comparisons within the test, and logic operators. Note that the numerical comparison uses -eq, -lt, etc., whereas the string uses = and!= in square brackets. The logic operators &&, >, and! combine several conditions into one branch.
Key points
- Arithmetic: add, subtract, multiply, divide, remaining in $(()
- The comparison of numbers: -eq -ne -lt -le -gt -ge
- Comparison of strings: = or!= and check -z and -n
- Logic: && or, not, and,! the opposite
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.