Utoljára aktív 1745377024

Арифметические операции в bash

LittleGreenCat's Avatar LittleGreenCat gist felülvizsgálása 1745377024. Revízióhoz ugrás

1 file changed, 1 deletion

bash.sh

@@ -20,5 +20,4 @@
20 20 [[ test_case_1 ]] && [[ test_case_2 ]] # And
21 21 [[ test_case_1 ]] || [[ test_case_2 ]] # Or
22 22
23 -
24 23 # Опубликовано в https://t.me/gitgate

LittleGreenCat's Avatar LittleGreenCat gist felülvizsgálása 1745377011. Revízióhoz ugrás

1 file changed, 24 insertions

bash.sh(fájl létrehozva)

@@ -0,0 +1,24 @@
1 + # Returns true if the numbers are equal
2 + [[ ${arg1} -eq ${arg2} ]]
3 +
4 + # Returns true if the numbers are not equal
5 + [[ ${arg1} -ne ${arg2} ]]
6 +
7 + # Returns true if arg1 is less than arg2
8 + [[ ${arg1} -lt ${arg2} ]]
9 +
10 + # Returns true if arg1 is less than or equal arg2
11 + [[ ${arg1} -le ${arg2} ]]
12 +
13 + # Returns true if arg1 is greater than arg2
14 + [[ ${arg1} -gt ${arg2} ]]
15 +
16 + # Returns true if arg1 is greater than or equal arg2
17 + [[ ${arg1} -ge ${arg2} ]]
18 +
19 + # As with other programming languages you can use AND & OR conditions:
20 + [[ test_case_1 ]] && [[ test_case_2 ]] # And
21 + [[ test_case_1 ]] || [[ test_case_2 ]] # Or
22 +
23 +
24 + # Опубликовано в https://t.me/gitgate
Újabb Régebbi