Linux grep命令

常常会遇到这样的状况:html

一、在单个文件中查找某个关键字linux

二、经过日志去分析用户行为正则表达式

三、一天的日志被分割成多个文件,要在这多个文件中查找(正则表达式查找)api

。。。spa

好比,我这里须要根据用户ID查找日志

这里用到的命令主要是: grep 和  findhtm

find用于查找文件,grep用于查找文件中的内容,两者配合,经过管道就能够实现多文件查找blog

有条件的话,用ELK固然好了,或者AWK get

然鹅……我不会……io

先看下效果

备忘单

find -name "api.kaishustory.com.access_20190708*.log" | xargs grep -E ".*period\/info.*111875007.*"

 

https://www.runoob.com/linux/linux-comm-grep.html

https://www.runoob.com/linux/linux-comm-find.html

https://www.runoob.com/linux/linux-comm-xargs.html

相关文章
相关标签/搜索