1753344 Members
5239 Online
108792 Solutions
New Discussion

Command required

 
SOLVED
Go to solution
mjoshi
Trusted Contributor

Command required

Dear,

netstat – an | grep ESTABLISHED |wc –l

require output for this file only if the cont is more than 8000


With Regards
Mjoshi
4 REPLIES 4
Solution

Re: Command required

Hi,

x=$(netstat -an | grep ESTABLISHED | wc -l); [ ${x} -ge 8000 ] && echo ${x}

should do it

HTH

Duncan

I am an HPE Employee
Accept or Kudo
mjoshi
Trusted Contributor

Re: Command required

Is this the direct cmd need to executed? or is it the script i need to work on?

Re: Command required

unless you actually wanted the output of netstat in which case:

[ $(netstat -an | grep ESTABLISHED | wc -l) -ge 8000 ] && netstat -an | grep ESTABLISHED

Not very efficient, but does the trick...

HTH

Duncan

I am an HPE Employee
Accept or Kudo

Re: Command required

>> Is this the direct cmd need to executed? or is it the script i need to work on?

well a script is just a set of commands bundled togther so it's both...

HTH

Duncan

I am an HPE Employee
Accept or Kudo