gregs

helping me remember what I figure out

tail | grep

| 5 Comments

After reading a quote on a mailing list last week about the concept behind unix tools and their focus on doing one task well and the OS allowing you to pipe several commands in one go, it dawned on me that I could do the following on log files:

CODE:
  1. tail -f /var/log/syslog | grep "named"

So as the log fills up only items where the pattern "named" is found are displayed. Very neat!

UPDATE

Thanks to some of the comments, here's a way to colour code the output (hopefully this will render better than the comment output)

CODE:
  1. tail -f /var/log/syslog | grep "named" --color

5 Comments

  1. Oh, I just found this through Google. It was exactly what I was looking for, but I never thought it’d be *this* simple. Heehee.

  2. Even better use “tail -f /var/log/logfile | grep pattern –color” to highlight the individual matched pattern

  3. The colour coding ability is a great addition, thanks Liam!

  4. Nice man it’s what I looking for ;) ,

  5. Exactly what I was looking for thank you!

Leave a Reply

Required fields are marked *.

*