Skip to content

Instantly share code, notes, and snippets.

@Memphizzz
Created April 5, 2019 13:30
Show Gist options
  • Save Memphizzz/e4afbe717ee48c0806ad69b4533dacea to your computer and use it in GitHub Desktop.
Save Memphizzz/e4afbe717ee48c0806ad69b4533dacea to your computer and use it in GitHub Desktop.
while read event target lost ; do
case $event in
NEW )
ip2int $target intTarget
((count[intTarget]++))
...
esac
done < <(tail -f /path/logfile | sed -une '
s/^.*New incom.*from ip \([0-9.]\+\) .*$/NEW \1/p;
s/^.*Auth.*ip \([0-9.]\+\) failed./FAIL \1/p;
...
')
@kseistrup
Copy link

How about something like

tail -f … \
| while read event target lost
    switch $event
      case NEW
        do_something
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment