#!/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/50427281spa