- shell判斷文件,目錄是否存在或者具有權限 ??
- ??#!/bin/sh ??
- ??
- myPath= "/var/log/httpd/" ??
- myFile= "/var?/log/httpd/access.log" ??
- ??
- #這里的-x?參數判斷$myPath是否存在并且是否具有可執行權限 ??
- if ?[?!?-x? "$myPath" ];?then ??
- mkdir? "$myPath" ??
- fi ??
- ??
- #這里的-d?參數判斷$myPath是否存在 ??
- if ?[?!?-d? "$myPath" ];?then ??
- mkdir? "$myPath" ??
- fi ??
- ??
- #這里的-f參數判斷$myFile是否存在 ??
- if ?[?!?-f? "$myFile" ?];?then ??
- touch? "$myFile" ??
- fi ??
- ??
- #其他參數還有-n,-n是判斷一個變量是否是否有值 ??
- if ?[?!?-n? "$myVar" ?];?then ??
- echo? "$myVar?is?empty" ??
- exit? 0 ??
- fi ??
- ??
- #兩個變量判斷是否相等 ??
- if ?[? "$var1" ?=? "$var2" ?];?then ??
- echo? '$var1?eq?$var2' ??
- else ??
- echo? '$var1?not?eq?$var2' ??
- fi??
只有注冊用戶登錄后才能發表評論。 | ||
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
![]() |
||
相關文章:
|
||
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
|
||
|