понедельник, 26 марта 2018 г.

Bash. Сравнения.

Сравнение файлов:

-d my_file Checks if its a folder.

-e my_file Checks if the file is available.

-f my_file Checks if its a file.

-r my_file Checks if it’s readable.

my_file –nt my_file2 Checks if my_file is newer than my_file2.

my_file –ot my_file2 Checks if my_file is older than my_file2.

-O my_file Checks if the owner of the file and the logged user match.

-G my_file Checks if the file and the logged user have the idetical group.




Сравнение чисел:

number1 -eq number2 Checks if number1 is equal to number2.

number1 -ge number2 Checks if number1 is bigger than or equal number2.

number1 -gt number2 Checks if number1 is bigger than number2.

number1 -le number2 Checks if number1 is smaller than or equal number2.

number1 -lt number2 Checks if number1 is smaller than number2.

number1 -ne number2 Checks if number1 is not equal to number2.


Сравнение строк:

-n string1 Checks if string1 longer than zero.

-z string1 Checks if string1 is zero length.

string1 = string2 Checks if string1 identical to string2.

string1 != string2 Checks if string1 is not identical to string2.

string1 < string2 Checks if string1 is less than string2.

string1 > string2 Checks if string1 is greater than string2.

Комментариев нет:

Отправить комментарий