Alas, I didn't learn shell, and my colleagues encountered a problem. I asked my classmates if it was necessary to learn it. It wasn't complicated, but the syntax was too strange and I really didn't understand it.
I wrote a simple script.
#! /Bin/sh
Number = 1
Max = 3
While ["$ number"-Le "$ Max"]
Do
Echo "this is $ number cycle start ......"
Number = $ number + 1
Done
Echo "over ..."
The error message returned when the number = $ number + 1 line does not work.
So I want to refer to the following article (the shell format is very demanding, for example, after the while clause [] there must be a space number + there must be a Space Variable assignment on both sides = no space)
1. expr is used to calculate the expression value.
Expr expression1 operator expression2
'\' Must be added before the operator for escape, and there must be spaces between the operator and two expressions.
Count = 1
Count = 'expr $ count + 1)
Echo $ count
The output is 2.
2. It is better to replace $ () with higher efficiency.
Count = 1
Count = $ ($ count + 1 ))
Echo $ count
3. You can also use $ []
Var = $[1 + 5]
Echo $ var // 6
Count = 1
Var = $ [$ count + 1]
Echo $ VaR