Using grep to get the next WORD after a match in each line

前端 未结 6 1327
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 07:09

I want to get the \"GET\" queries from my server logs.

For example, this is the server log

1.0.0.127.in-addr.arpa - - [10/Jun/2012          


        
6条回答
  •  一整个雨季
    2020-11-30 07:40

    use a pipe if you use grep:

    grep -o /he.* log.txt | grep -o [^/].*
    grep -o /ss log.txt | grep -o [^/].*
    

    [^/] means extract the letters after ^ symbol from the grep output

提交回复
热议问题