shell判断参数

    * -b file = True if the file exists and is block special file.     如果该文件存在并且是块特殊文件。
    * -c file = True if the file exists and is character special file.如果该文件存在并且是字符特殊文件
    * -d file = True if the file exists and is a directory.   如果该文件存在并且是一个目录。
    * -e file = True if the file exists.         如果该文件存在
    * -f file = True if the file exists and is a regular file   如果该文件存在并且是一个普通文件
    * -g file = True if the file exists and the set-group-id bit is set.   如果该文件存在并且设置了组ID位。
    * -k file = True if the files’ “sticky” bit is set.    如果文件的sticky “粘性”位被设置。
    * -L file = True if the file exists and is a symbolic link.   该文件存在并且是一个符号链接。
    * -p file = True if the file exists and is a named pipe.   该文件存在并且是一个命名管道。
    * -r file = True if the file exists and is readable.   文件存在并且是可读的
    * -s file = True if the file exists and its size is greater than zero. 文件存在,它的大小是大于零
    * -S file = True if the file exists and is a socket.     文件存在并且是一个套接字
    * -t fd = True if the file descriptor is opened on a terminal.   文件描述符是在一个终端上打开的
    * -u file = True if the file exists and its set-user-id bit is set. 文件存在,它的设置用户ID位被设置了
    * -w file = True if the file exists and is writable.     文件存在并且可写
    * -x file = True if the file exists and is executable.     文件存在并且是可执行的
    * -O file = True if the file exists and is owned by the effective user id.    文件存在并且是所拥有的有效用户ID
    * -G file = True if the file exists and is owned by the effective group id. 文件存在并且拥有有效的gruop id。


    * file1 -nt file2 = True    if file1 is newer, by modification date, than file2.     如果file1更新
    * file1 ot file2 = True    if file1 is older than file2.         如果file1更旧
    * file1 ef file2 = True     if file1 and file2 have the same device and inode numbers.file1和file2有相同的设备和节点号
    * -z string = True if the length of the string is 0.        字符串的长度为0
    * -n string = True if the length of the string is non-zero.   字符串的长度不为零
    * string1 = string2 = True if the strings are equal.
    * string1 != string2 = True if the strings are not equal.
    * !expr = True if the expr evaluates to false.
    * expr1 -a expr2 = True if both expr1 and expr2 are true.     且为真
    * expr1 -o expr2 = True is either expr1 or expr2 is true.       或


两个档案之间的判断与比较 ;例如『 test file1 -nt file2 』
    * -nt 第一个档案比第二个档案新
    * -ot 第一个档案比第二个档案旧
    * -ef 第一个档案与第二个档案为同一个档案( link 之类的档案)

逻辑的『和(and)』『或(or)』
    * && 逻辑的 AND 的意思
    * || 逻辑的 OR 的意思


运算符号 代表意义
= 等于
!= 不等于
< 小于
> 大于
-eq 等于
-ne 不等于
-lt 小于
-gt 大于
-le 小于或等于
-ge 大于或等于
-a 双方都成立(and)
-o 单方成立(or)
-z 空字符串
-n 非空字符串

猜你喜欢

转载自luocb1980.iteye.com/blog/940805
今日推荐