Shell C Shell運算符

2021-08-31 09:54 更新
本教程列出了所有C Shell的運算符。在這里,大部分的運算符都是跟C語言編程很相似。

運算符優(yōu)先級遞減的順序如下:

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

運算符 描述
( ) Change precedence
~ 1's complement
! Logical negation
* 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
*= Multiply left side by right side and update left side
/= Divide left side by right side and update left side
+= Add left side to right side and update left side
-= Subtract left side from right side and update left side
^= "Exclusive or" left side to right side and update left side
%= Divide left by right side and update left side with remainder

文件測試操作:

有以下操作測試與Unix文件相關(guān)聯(liá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.
-z 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.
-o file Check if user owns the file. It returns true if user is the owner of the file.

 




以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號