092-shell中的-n 參數的使用

if [ ! -n "$myVar" ]; then 
echo "$myVar is empty" 
exit 0 
fi

! 爲不的意思 code

-n 的意思是字符串長度爲0則爲假, 不是0,有數值則爲真 -n $myVar 中,當$myVar有數值時,則不爲空,即不爲0,符合-n的判斷標準,繼續走到echo 若是-n前面加上!,則是真的對立面,爲假,直接跳出循環字符串

相關文章
相關標籤/搜索