093-grep -q參數

grep -q 用於if邏輯判斷,shell

-q 參數,本意是 Quiet; do not write anything to standard output.  Exit immediately with zero status if any match is found, even if an error was detected.   中文意思爲,安靜模式,不打印任何標準輸出。若是有匹配的內容則當即返回狀態值0。ui

         echo '1234' | grep -q 12

         echo $? 輸出 0

         echo '1234' | grep 45

         echo $? 輸出 1
相關文章
相關標籤/搜索