Posted over 6 years ago. Visible to the public.

How to combine greps on log files opened with tail -f

In order to chain greps on log files that are opened via tail -f test.log you have to use the --line-buffered command line option for grep.

Imagine you have the following content in your log file.

Copy
# content for log/test.log test foo bar test foo bar baz bla

Now if you would like to grep for lines that contain foo but not bar, you can use the following command chain:

Copy
$ tail -f log/test.log | grep --line-buffered "foo" | grep -v "bar" Output: test foo

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Ulrich Berkmueller
Last edit:
over 5 years ago
Keywords:
chain, multiple
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Ulrich Berkmueller to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more