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