Linux grep命令

经常会遇到这样的情况:

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

2、通过日志去分析用户行为

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

。。。

比如,我这里需要根据用户ID查找

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

find用于查找文件,grep用于查找文件中的内容,二者配合,通过管道就可以实现多文件查找

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

然鹅……我不会……

先看下效果

备忘单

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

 

posted @ 2019-07-11 20:11  废物大师兄  阅读(1672)  评论(0编辑  收藏  举报