Home > Article > Operation and Maintenance > Introduction to the built-in judgment statements of the shell in Linux
Built-in judgment, returns 0 when successful and non-zero when unsuccessful. Next, this article will focus on introducing the built-in judgment statements of the Linux shell. Friends who are interested should take a look.
Built-in judgment, returns 0 when successful, and returns non-zero if unsuccessful
Test Judgment expression
[Judgment expression] Note that spaces must be left before and after
Numerical operations
-eq Equal to
- ne Not equal to
-gt Greater than
-ge Greater than or equal to
-lt Less than
-le Less than or equal to
String operation
= Equal to
!= Not equal to
-z Whether it is empty
-n Whether it is not empty
File operation
-r Whether it exists and can be read
-w Whether it exists and can be written
-x Whether it exists and can be executed
-f Does this file exist?
-d Does this directory exist?
The above is the detailed content of Introduction to the built-in judgment statements of the shell in Linux. For more information, please follow other related articles on the PHP Chinese website!