鍍金池/ 教程/ Linux/ Korn Shell 運(yùn)算符
Shell 輸入/輸出重定向
Shell 循環(huán)類(lèi)型
Shell是什么?
Shell 特殊變量
Shell 算術(shù)運(yùn)算符示例
Shell 關(guān)系運(yùn)算符示例
Shell 替代
Shell 函數(shù)
Shell 條件語(yǔ)句
Shell 聯(lián)機(jī)幫助
Shell 數(shù)組/Arrays
Shell 布爾運(yùn)算符范例
Shell
Shell if...elif...fi 語(yǔ)句
Shell case...esac 語(yǔ)句
Shell 使用Shell變量
Shell 文件測(cè)試符例子
Shell 基本運(yùn)算符
Korn Shell 運(yùn)算符
Shell 字符串運(yùn)算范例
Shell while 循環(huán)
Shell 引用機(jī)制
Shell if...else...fi 語(yǔ)句
Shell select 循環(huán)
C Shell運(yùn)算符
Shell 循環(huán)控制break/continue
Shell for循環(huán)
Shell until 循環(huán)
Shell if...fi語(yǔ)句

Korn Shell 運(yùn)算符

本教程列出了所有Korn Shell中的運(yùn)算符。在這里,大部分的運(yùn)算符都是我們熟知的C語(yǔ)言編程很相似。

運(yùn)算符優(yōu)先級(jí)遞減的順序如下列出:

算術(shù)和邏輯運(yùn)算符:

運(yùn)算符 描述
+ 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

文件測(cè)試操作:

有以下運(yùn)算符測(cè)試可用在Unix文件中的相關(guān)聯(lián)各種屬性。

運(yùn)算符 描述
-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.


上一篇:Shell 使用Shell變量下一篇:Shell