• Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp

Posts tagged tail

BASH> Tail multiple files & highlight

Oct26
2010
Written by Scott Rowley

Tail multiple files at once:

tail -f log1.log log2.log

If you want to highlight something when doing ‘tail -f’ you can use the following command:

tail -f /var/log/logfile | perl -p -e 's/(SEARCH)/33[7;1m$133[0m/g;'

Or if your terminal supports colours, such as linux terminal, you can use this:

tail -f /var/log/logfile | perl -p -e 's/(SEARCH)/33[46;1m$133[0m/g;'

And if you want it to beep (annoy you!) on a match use this:

tail -f /var/log/logfile | perl -p -e 's/(SEARCH)/33[46;1m$133[0m07/g;'

Another option using sed instead:

tail -f /var/log/logfile | sed "s/(SEARCH)/^[[46;1m1^[[0m/g"

Note that in the last example you have to actually type “cntl-v cntl-[” in place of “^[”

For a full list of control characters on Linux see:

man console_codes
Posted in BASH - Tagged BASH, highlight, sed

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top