Полезная информация

Learning the Korn Shell

Learning the Korn ShellSearch this book
Previous: B.3 Built-in Shell VariablesAppendix B
Reference Lists
Next: B.5 Options
 

B.4 Test Operators

These are the operators that are used with the [[...]] construct. They can be logically combined with && ("and") and || ("or") and grouped with parenthesis.
OperatorTrue If...
-a filefile exists.
-b filefile is a block device file.
-c filefile is a character device file.
-d filefile is a directory.
-f filefile is a regular file.
-g filefile has its setgid bit set.
-k filefile has its sticky bit set.
-n stringstring is non-null.
-o optionoption is set.
-p filefile is a pipe or named pipe (FIFO file).
-r filefile is readable.
-s filefile is not empty.
-t NFile descriptor N points to a terminal.
-u filefile has its setuid bit set.
-w filefile is writeable.
-x file

file is executable, or file is a directory that can be searched.

-z stringstring is null.
-G filefile's group ID is the same as that of the shell.
-L filefile is a symbolic link.
-O filefile is owned by the shell's user ID.
-S filefile is a socket.
fileA -nt fileBfileA is newer than fileB.
fileA -ot fileBfileA is older than fileB.
fileA -ef fileB

fileA and fileB point to the same file.

string = pattern

string matches pattern (which can contain wildcards).

string != patternstring does not match pattern.
stringA < stringB

stringA comes before stringB in dictionary order.

stringA > stringB

stringA comes after stringB in dictionary order.

exprA -eq exprB

Arithmetic expressions exprA and exprB are equal.

exprA -ne exprB

Arithmetic expressions exprA and exprB are not equal.

exprA -lt exprBexprA is less than exprB.
exprA -gt exprBexprA is greater than exprB.
exprA -le exprBexprA is less than or equal to exprB.
exprA -ge exprBexprA is greater than or equal to exprB.


Previous: B.3 Built-in Shell VariablesLearning the Korn ShellNext: B.5 Options
B.3 Built-in Shell VariablesBook IndexB.5 Options

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System