ansible 的常用模块中没有判定当文件存在或者不存在时,执行某个执行 使用下面方法能简单判定某个文件是否存在 --- - name: judge a file or dir is exits shell: ls /home/sfy ignore_errors: True register: result - shell: echo "file exit" when: result|succeeded - shell: echo "file not exit" w
判断方法: DirectoryInfo di = new DirectoryInfo(path); if ((di.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) //为隐藏的 同理可以判断目录是否为只读(ReadOnly)或者系统(System)等其他属性.
FUNCTION WritableDir(CONST Dir : STRING) : BOOLEAN; VAR FIL : FILE; N : STRING; I : Cardinal; BEGIN REPEAT N:=IncludeTrailingPathDelimiter(Dir); FOR I:= TO -LENGTH(N) DO N:=N+CHAR(RANDOM()+) UNTIL NOT FileExists(N); Result:=TRUE; TRY AssignFile(FIL,N
https://www.cnblogs.com/37yan/p/6962563.html caution!!! if should be end with fi caution!!! there should be a space between [ and ! , also between 1 and ] if [ ! $# -eq 1 ];then #!/bin/bash # 判断传入的参数的个数是不是一个 ];then echo param error! exit fi # 判断目录是不是