Windows下wc,grep统计脚本

如果还是不行,给你一个VBScript的程序(Windows的脚本)

Function grep(sSearch, sFileName)
SET FSO = CreateObject("Scripting.FileSystemObject")
SET FP = FSO.OpenTextFile(sFileName, 1, FALSE)
If Err.Number <> 0 Then
WScript.Echo ("Error " & CStr(Err.Number) & " " & Err.Description)
EXIT Function
End If
i = 1
count = 0
Do Until FP.AtEndOfStream
sLine = FP.ReadLine
If sLine<>vbNull Then
Z = InStrRev(sLine, sSearch)
If Z>0 Then
'WScript.Echo i & " : " & sLine
count = count + 1
End If
End If
i = i + 1
Loop
grep = count
End Function

Set args = WScript.Arguments
count = grep(args(0), args(1))
WScript.Echo "Total Count = " & count

保存成 grep.vbs,放在系统环境变量PATH的某个路径下,或者是当前路径,
然后执行
grep "GET /CI/system/application/controllers/tongji.php" access.log

也能出结果。

-----------------------------------
查找统计
@echo off
netstat -an|find "8082"|find "ESTABLISHED" > c:\tongji.txt

for /f %%a in (' find /c /v "" ^<"c:\tongji.txt" ') do set n=%%a
echo
grep "ESTABLISHED" c:\tongji.txt

你可能感兴趣的:(windows)