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

Posted DamonWong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux bash shell 判断目录是否为空的函数相关的知识,希望对你有一定的参考价值。

#!/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 判断目录是否为空的函数的主要内容,如果未能解决你的问题,请参考以下文章