Browse Source

fragments/color-tail: a perl oneliner for highlighting stuff

main
Brennen Bearnes 1 year ago
parent
commit
52e5eeb3fb
3 changed files with 11 additions and 0 deletions
  1. +3
    -0
      home/fragments/color-tail/README
  2. +6
    -0
      home/fragments/color-tail/my.log
  3. +2
    -0
      home/fragments/color-tail/oneliner.sh

+ 3
- 0
home/fragments/color-tail/README View File

@ -0,0 +1,3 @@
A oneliner for highlighting a particular value with Perl while tailing a logfile.
See: https://mastodon.social/@brennen/105121038246001991

+ 6
- 0
home/fragments/color-tail/my.log View File

@ -0,0 +1,6 @@
Iteration duration for some thing with ten different fields: 10
Other noise
Iteration duration for some thing with ten different fields: 90
Other noise
Again, other noise
Iteration duration for some thing with ten different fields: 100

+ 2
- 0
home/fragments/color-tail/oneliner.sh View File

@ -0,0 +1,2 @@
#!/bin/sh
tail -F my.log | perl -lane 'if (/Iteration duration/) { $F[9] = "\e[1;35m$F[9]\e[0m" if $F[9] >= 90; print join(" ", @F) }'

Loading…
Cancel
Save