您的位置:首页 > 运维架构 > Shell

linux shell 学习之路---test判断是否为目录

2013-07-16 20:31 232 查看


linux shell 学习之路---test判断是否为目录

#!/bin/bash

if test -d "temp" 

then 

    echo "temp is a directory"

else

    echo "temp is not a directory"

fi

说明:如果temp是目录则输出temp is a directory;否则输出temp is not a directory;

            -d 对象存在且为目录返回值为“是”

        -f 对象存在且为文件返回值为“是”

        -L 对象存在且为符号连接返回值为“是”

        -r 对象存在且可读则返回值为“是”

        -s 对象存在且长度非零则返回值为“是”

        -w 对象存在且可写则返回值为“是”

        -x 对象存在且可执行则返回值为“是
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: