本教程列出了所有Korn Shell中的运算符。在这里,大部分的运算符都是我们熟知的C语言编程很相似。
运算符优先级递减的顺序如下列出:
算术和逻辑运算符:
| 运算符 | 描述 |
|---|---|
| + | Unary plus |
| - | Unary minus |
| !~ | Logical negation; binary inversion (one's complement) |
| * | Multiply |
| / | Divide |
| % | Modulo |
| + | Add |
| - | Subtract |
| << | Left shift |
| >> | Right shift |
| == | String comparison for equality |
| != | String comparison for non equality |
| =~ | Pattern matching |
| & | Bitwise "and" |
| ^ | Bitwise "exclusive or" |
| | | Bitwise "inclusive or" |
| && | Logical "and" |
| || | Logical "or" |
| ++ | Increment |
| -- | Decrement |
| = | Assignment |
文件测试操作:
有以下运算符测试可用在Unix文件中的相关联各种属性。
| 运算符 | 描述 |
|---|---|
| -r file | Checks if file is readable if yes then condition becomes true. |
| -w file | Check if file is writable if yes then condition becomes true. |
| -x file | Check if file is execute if yes then condition becomes true. |
| -f file | Check if file is an ordinary file as opposed to a directory or special file if yes then condition becomes true. |
| -s file | Check if file has size greater than 0 if yes then condition becomes true. |
| -d file | Check if file is a directory if yes then condition becomes true. |
| -e file | Check if file exists. Is true even if file is a directory but exists. |
上一篇:
C Shell运算符
下一篇:
Shell 条件语句
