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

linux shell判断目录是否为空的函数

2014-02-19 10:08 393 查看
linux shell判断目录是否为空的函数:

Folder_DEPLOY="/usr/local/deploy"

#判断目录是否为空的函数

function checkDerectory() {

if [ "`ls -A $Folder_DEPLOY`" = "" ]; then

//do something

echo true

else

//do something

echo false

fi

}

调用函数:

shell部分:

derecResult=$(checkDerectory)

if [[ $derecResult == true ]]; then

//do something

fi

说明:该方法是实际工作中自己用到的方法,先将其抽取出来,希望对有需要的朋友有些帮助。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: