xq8995209 发表于 2018-8-23 11:24:19

Linux Shell Test

  ( EXPRESSION )
  EXPRESSION is true          EXPRESSION为真
  ! EXPRESSION
  EXPRESSION is false      EXPRESSION为假
  EXPRESSION1 -a EXPRESSION2
  both EXPRESSION1 and EXPRESSION2 are true      两者都为真
  EXPRESSION1 -o EXPRESSION2
  either EXPRESSION1 or EXPRESSION2 is true      其中一个为真
  -n STRING
  the length of STRING is nonzero                字符串长度非0
  STRING equivalent to -n STRING
  -z STRING
  the length of STRING is zero                  字符串长度为0
  STRING1 = STRING2
  the strings are equal                     字符串相等
  STRING1 != STRING2
  the strings are not equal                  字符串不相等
  INTEGER1 -eq INTEGER2
  INTEGER1 is equal to INTEGER2               INTEGER1等于INTEGER2
  INTEGER1 -ge INTEGER2
  INTEGER1 is greater than or equal to INTEGER2      INTEGER1大于等于INTEGER2
  INTEGER1 -gt INTEGER2
  INTEGER1 is greater than INTEGER2            INTEGER1大于INTEGER2
  INTEGER1 -le INTEGER2
  INTEGER1 is less than or equal to INTEGER2      INTEGER1小于等于INTEGER2
  INTEGER1 -lt INTEGER2
  INTEGER1 is less than INTEGER2            INTEGER1小于INTEGER2
  INTEGER1 -ne INTEGER2
  INTEGER1 is not equal to INTEGER2            INTEGER1不等于INTEGER2
  FILE1 -ef FILE2
  FILE1 and FILE2 have the same device and inode numbers
  FILE1 -nt FILE2
  FILE1 is newer (modification date) than FILE2
  FILE1 -ot FILE2
  FILE1 is older than FILE2
  -b FILE
  FILE exists and is block special               文件存在且为块特殊文件
  -c FILE
  FILE exists and is character special            文件存在且为字符特殊文件
  -d FILE
  FILE exists and is a directory                文件存在且为目录
  -e FILE
  FILE exists                            文件存在
  -f FILE
  FILE exists and is a regular file            文件存在且为正规文件
  -g FILE
  FILE exists and is set-group-ID               文件存在且已设置组ID
  -G FILE

  FILE exists and is owned by the effective group>  -h FILE
  FILE exists and is a symbolic link (same as -L)    文件存在且为符号链接
  -k FILE
  FILE exists and has its sticky bit set          文件存在且已设置sticky-bit权限
  -L FILE
  FILE exists and is a symbolic link (same as -h)    文件存在且为符号链接
  -O FILE

  FILE exists and is owned by the effective user>  -p FILE
  FILE exists and is a named pipe
  -r FILE
  FILE exists and read permission is granted      文件存在且可读
  -s FILE

  FILE exists and has a>  -S FILE
  FILE exists and is a socket            文件存在且是socket文件
  -t FDfile descriptor FD is opened on a terminal
  -u FILE
  FILE exists and its set-user-ID bit is set   文件存在且已设置set-user-id bit权限
  -w FILE
  FILE exists and write permission is granted            文件存在且可写
  -x FILE
  FILE exists and execute (or search) permission is granted   文件存在且可执行

页: [1]
查看完整版本: Linux Shell Test