Son aktivite 1745376938

Условные выражения для строковых переменных в bash

Revizyon 442f3e12e841fca7a6a29d9f88452865efa5c92b

bash.sh Ham
1# True if the shell variable varname is set (has been assigned a value).
2[[ -v ${varname} ]]
3
4# True if the length of the string is zero.
5[[ -z ${string} ]]
6
7# True if the length of the string is non-zero.
8[[ -n ${string} ]]
9
10# True if the strings are equal. = should be used with the test command for POSIX conformance. When used with the [[ command, this performs pattern matching as described above (Compound Commands)
11[[ ${string1} == ${string2} ]]
12
13# True if the strings are not equal.
14[[ ${string1} != ${string2} ]]
15
16# True if string1 sorts before string2 lexicographically.
17[[ ${string1} < ${string2} ]]
18
19# True if string1 sorts after string2 lexicographically.
20[[ ${string1} > ${string2} ]]
21
22Опубликовано в https://t.me/gitgate
23