首页 > 系统服务 > 详细

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

时间:2017-10-09 20:16:56      阅读:366      评论:0      收藏:0      [点我收藏+]
#!/bin/sh
##方法一 判断输出字符数统计为0
is_empty_dir(){ 
    return `ls -A $1|wc -w`
}
##方法二 判断输出string为空
#is_empty_dir(){ 
#   return $[ -z `ls -A $1` ]
#}

if is_empty_dir $1
then
    echo " $1 is empty"
else
    echo " $1 is not empty"    
fi

注:参考连接:http://blog.csdn.net/10km/article/details/50427281

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

原文:http://www.cnblogs.com/kings-9/p/7642654.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!