欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linux下grep查找带有空格的字符串

程序员文章站 2022-03-11 11:45:30
...

例如查找包含字符串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'
相关标签: grep