在给项目中的Windows批处理脚本中,需要查找结果中包含字符串A,或者包含字符串B,就写入一个文本文件,
查阅了findstr中的方法,希望找一个类似正则表达式那样的方法,但没找到,就反复试验,找到一个方法,
例如执行了nestat命令,结果中连接状态是TIME_WAIT或者是CLOSE_WAIT的,可以这样写:
D:\data>netstat -ant | findstr "TIME_WAIT CLOSE_WAIT"
TCP 10.20.5.143:50189 111.202.88.154:80 CLOSE_WAIT InHost
TCP 10.20.5.143:50224 111.202.88.154:80 CLOSE_WAIT InHost
TCP 10.20.5.143:56611 119.249.48.228:80 CLOSE_WAIT InHost
TCP 10.20.5.143:58627 163.177.71.178:80 CLOSE_WAIT InHost
TCP 10.20.5.143:58697 153.37.209.8:80 CLOSE_WAIT InHost
TCP 10.20.5.143:58875 220.194.95.147:443 CLOSE_WAIT InHost
TCP 10.20.5.143:58914 202.108.23.152:443 CLOSE_WAIT InHost
TCP 10.20.5.143:58916 220.195.22.133:443 TIME_WAIT InHost
TCP 10.20.5.143:58918 220.195.22.129:443 CLOSE_WAIT InHost
TCP 10.20.5.143:58920 111.202.114.81:443 CLOSE_WAIT InHost
TCP 10.20.5.143:58922 123.125.115.99:443 CLOSE_WAIT InHost
TCP 10.20.5.143:58923 123.125.115.99:443 CLOSE_WAIT InHost
TCP 10.20.5.143:58928 123.125.114.111:443 CLOSE_WAIT InHost
TCP 10.20.5.143:58933 123.125.114.111:443 CLOSE_WAIT InHost
TCP 10.20.5.143:58934 202.108.23.152:443 CLOSE_WAIT InHost
TCP 10.20.5.143:58955 218.241.149.65:80 TIME_WAIT InHost
TCP 10.20.5.143:58958 123.125.114.104:80 TIME_WAIT InHost
TCP 10.20.5.143:58959 218.241.149.66:80 TIME_WAIT InHost