SHELL TEST operators

Operator

True if...

-a file

file exists

-b file

file exists and is a block device file

-c file

file exists and is a character device file

-d file

file exists and is a directory

-e file

file exists; same as -a

-f file

file exists and is a regular file

-g file

file exists and has its setgid bit set

-G file

file exists and is owned by the effective group ID

-h file

file exists and is a symbolic link

-k file

file exists and has its sticky bit set

-L file

file exists and is a symbolic link

-n string

string is non-null

-N file

file was modified since it was last read

-O file

file exists and is owned by the effective user ID

-p file

file exists and is a pipe or named pipe (FIFO file)

-r file

file exists and is readable

-s file

file exists and is not empty

-S file

file exists and is a socket

-t N

File descriptor N points to a terminal

-u file

file exists and has its setuid bit set

-w file

file exists and is writeable

-x file

file exists and is executable, or file is a directory that can be searched

-z string

string has a length of zero

fileA -nt fileB

fileA modification time is newer than fileB

fileA -ot fileB

fileA modification time is older than fileB

fileA -ef fileB

fileA and fileB point to the same file

stringA = stringB

stringA equals stringB (POSIX version)

stringA == stringB

stringA equals stringB

stringA != stringB

stringA does not match stringB

stringA =~ regexp

stringA matches the extended regular expression regexp[3]

stringA < stringB

stringA sorts before stringB lexicographically

stringA > stringB

stringA sorts after stringB lexicographically

exprA -eq exprB

Arithmetic expressions exprA and exprB are equal

exprA -ne exprB

Arithmetic expressions exprA and exprB are not equal

exprA -lt exprB

exprA is less than exprB

exprA -gt exprB

exprA is greater than exprB

exprA -le exprB

exprA is less than or equal to exprB

exprA -ge exprB

exprA is greater than or equal to exprB

exprA -a exprB

exprA is true and exprB is true

exprA -o exprB

exprA is true or exprB is true



转载于:https://my.oschina.net/whwei1982/blog/157947

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值