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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM