How to use Continuously (-c) with grep on netstat?

1

How can I use netstat -c option with grep without repeating the info?

Example:

sudo netstat -tapc (works fine)

I want to do the same but only for the http lines:

sudo netstat -tapc | grep http

The code above generates duplicated lines.

How to track the -tapc info only for the http lines?

Harold Finch

Posted 2014-12-20T14:36:09.457

Reputation: 115

Answers

3

It appears that you need to forget netstat -c and use watch instead:

watch 'netstat -tap|grep http'

You may want to add options to watch, including -n to set the repetition rate, and -d to highlight differences.

AFH

Posted 2014-12-20T14:36:09.457

Reputation: 15 470