Overnight the application lost its database connection twice. To investigate, you need every line of the log app.log that records an error. The developers write them however they like: ERROR, Error: or err= with an error number, and err=0 means there was no error. Start with the search that first comes to mind.
Search the log for errors
In ~/grep-lab, search app.log for lines with errors: first by the word error, then by its beginning, err, ignoring case.
First, predict
What will the first command, grep error app.log, print?
Now start the exercise, run the command and compare your prediction with the output.
Why did grep error print the line login ok user=terror?
-
grep does not look for similar words:
grep errror app.logprints nothing. It looks for the pattern's characters in a row. -
Without options, grep prints no neighbouring lines: the line before terror, with err=5, is not in the output.
-
grep does tell case apart: there are no ERROR lines in the output. The grep alias on Ubuntu only adds colour — check with
alias grep.
The pattern error matched the end of the word terror.