Skip to content

Instantly share code, notes, and snippets.

@jdeathe
Last active April 20, 2024 08:43
Show Gist options
  • Save jdeathe/f13968cc7592f8a9c9c0693a29c8442c to your computer and use it in GitHub Desktop.
Save jdeathe/f13968cc7592f8a9c9c0693a29c8442c to your computer and use it in GitHub Desktop.
How to Grep the Output of tail

How to grep the output of tail

When following a log file with the tail command you are typically looking for a specific pattern. If the log output is verbous it can be difficult to catch the lines your interested in. For example a PHP log file might contain many PHP Notice: entries but your only interested in lines containing PHP Fatal error:. To grep the output of tail simply tell the grep command to red from stdin and pipe the output from tail to grep as follows.

tail -f {path/to/log/file} | grep 'PHP Fatal error:' -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment