cancel
Showing results for 
Search instead for 
Did you mean: 

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
Duncan Edmonstone
Honored Contributor
Solution

Re: Command required

Hi,

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

should do it

HTH

Duncan

HTH

Duncan
mjoshi
Trusted Contributor

Re: Command required

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

Duncan Edmonstone
Honored Contributor

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

HTH

Duncan
Duncan Edmonstone
Honored Contributor

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

HTH

Duncan