0

The server log is too large, I would like to grep the logs which has "/API/login" and "/API/init" from the server log.

I'm able to use:

tail -f /server.log | grep -i "/API/login"

to capture those with "/API/Login"

How to add in another condition to include "/API/init" as well?

I've tried this but couldnt work:

tail -f /server.log | grep -i "/API/login" || grep -i "/API/init"

Another thing is how to output this filtered logs to a text file?

Thank you.

Tech
  • 3
  • 1

1 Answers1

1

You can do it with -e flag

From the man page:

-e pattern, [...] This option is most useful when multiple -e options are used to specify multiple patterns, or when a pattern begins with a dash (`-').


 tail -f /server.log | grep -ei "/API/login" -ei "/API/init"

Petter H
  • 3,443
  • 1
  • 16
  • 19