There were a number of other threads like this, but the usual conclusion was something like "Install File::Tail". But, I'm on an old box that we're decomissioning, and I just want to write a one-liner to monitor a log. I tried installing File::Tail, but the environment for CPAN just isn't working, and I don't want to take the time to figure out what the problem is.
I just want a basic script that parses out an IP address and keeps a count of it for me. For some reason, though, even this simple test doesn't work:
$ tail -f snmplistener.log|grep IPaddress |perl -ne 'print "LINE: $_\n";'
I think it has something to do with output buffering, but I've always been a bit fuzzy on how that works. How can I get this one-liner working?
while(<>) { echo $_ }
type thing going. – Northeastergrep(1)
and justperl -lne 'print "LINE: $_" if /IPaddress/'
? – Magnify-n
adds awhile (<>) { ... }
around the provided code. – Rutaceous-n
flag. Perl will read from<>
automatically :) – Magnify