导航

shell条件判断中-a至-z的含义

Posted on 2016-11-02 17:38  Fundyqds  阅读(503)  评论(0编辑  收藏  举报

[ -a file ] ------- 如果file存在,返回值为真。

[ -b file ] ------- 如果file存在且为块特殊文件,返回值为真。

[ -c file ] ------- 如果file存在且为字特殊文件,返回值为真。

[ -d file ] ------- 如果file存在且为目录,返回值为真。

[ -e file ] ------- 如果file存在,返回值为真。

[ -f file ] ------- 如果file存在且为普通文件,返回值为真。

[ -g file ] ------- 如果file存在且已设置SGID,返回值为真。

[ -h file ] ------- 如果file存在且为符号链接,返回值为真。

[ -k file ] ------- 如果file存在且以设置粘滞位,返回值为真。

[ -p file ] ------- 如果file存在且为管道名,返回值为真。

[ -r file ] ------- 如果file存在且可读,返回值为真。

[ -s file ] ------- 如果file存在且大小不为0,返回值为真。

[ -t file ] ------- 如果file以打开且指向一个终端,返回值为真。

[ -u file ] ------- 如果file存在且已设置SUID,返回值为真。

[ -w file ] ------- 如果file存在且可写,返回值为真。

[ -x file ] ------- 如果file存在且可执行,返回值为真。

[ -O file ] ------- 如果file存在且属于有效用户ID,返回值为真。

[ -G file ] ------- 如果file存在且属于有效用户组,返回值为真。

[ -L file ] ------- 如果file存在且为符号链接,返回值为真。

[ -S file ] ------- 如果file存在且为套接字,返回值为真。

[ -z string ] ------- string的长度为0,返回值为真。

[ -n string ] ------- string的长度不为0,返回值为真。