1. 程式人生 > >linux下grep查詢帶有空格的字串

linux下grep查詢帶有空格的字串

例如查詢包含字串push success ! deviceId的內容

# 使用‘\’轉義空格,如果查詢的字串包含特殊字元,需要使用‘\’轉義
tail -f normal.log | grep push\ success\ \!\ deviceId
cat normal.log | grep push\ success\ \!\ deviceId
tail -f normal.log | grep \"dataType\":11
# 使用''單引號包裹查詢字串
tail -f normal.log | grep 'push success ! deviceId:'
cat normal.log | grep 'push success ! deviceId:'
tail -f normal.log | grep '"dataType":11'