I'm trying to write a script that will tail to a log. I want to monitor my localmachine listening ports.
I was working with this here:
netstat -anp | grep 0.0.0.0:* | grep LISTEN
This prints to the screen ... I want to output it to a log to monitor incoming local ports.
I've tried this:
netstat -anpo 7 | grep 0.0.0.0:* | grep LISTEN
Hoping that this would refresh every 7 seconds on the screen and grep the data.
Oh and I have tried this:
netstat -anpo 7 >/tmp/test12 | grep "LISTEN" | grep "0.0.0.0:*" | tail -f /tmp/test12
Any idea's how I can leave the terminal open to refresh my output? Are my greps all wrong? or maybe I need to use an "awk"... still learning thx