使用read超時參數便可解決:html
ex:shell
read -t5 DIR < <(df) if [ -n "$DIR" ];then echo $DIR else echo "read error" fi
感謝谷歌,方法出自:http://dbaspot.com/shell/404467-check-nfs-mount-script.htmlbash