Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1219953
  • 博文数量: 135
  • 博客积分: 10576
  • 博客等级: 上将
  • 技术积分: 1670
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-11 20:49
个人简介

不疯魔,不成活! --疯魔老杨(Crazy.LaoYang) http://www.inotes.cn/

文章分类

全部博文(135)

文章存档

2014年(4)

2012年(13)

2011年(5)

2010年(30)

2009年(56)

2008年(27)

分类: WINDOWS

2010-03-16 07:19:53

windows下统计查询结果的行数
(源自:杨志刚 博客 http:/yangzhigang.cublog.cn)
 
以统计TCP连接数为例:
如在linux下就很方便,大家也都知道,就是用:
//查行数
netstat -ant | grep ESTABLISHED | wc -l
 
//查行数+内容
netstat -ant | grep ESTABLISHED | wc -l;netstat -ant | grep ESTABLISHED
 
//查行数+分隔符+内容
netstat -ant | grep ESTABLISHED | wc -l;echo -------------------------;netstat -ant | grep ESTABLISHED
 
//(查行数+分隔符+内容)/每两秒
watch "netstat -ant | grep ESTABLISHED | wc -l;echo --------------;netstat -ant | grep ESTABLISHED" 
 
但是在windows下,默认是没有grep和wc的,如统计行数可以使用下面方法:
//查行数
netstat -an -p tcp | find /c "ESTABLISHED"
 
//(查行数+分隔符+内容)/每两秒,要用BAT了
@echo off
@title get_netstat_status
@color 1a
 
:start
netstat -an -p tcp | find /c "ESTABLISHED"
echo ----------------------
netstat -an -p tcp | find "ESTABLISHED"
ping -n 2 127.0.0.1 > NULL
goto :start
 
 
阅读(3351) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~