CODE: [Copy to clipboard]
::findmsisdn.bat - 查找固定模式文本内容中含有MS PURGED IN SGSN、MS PURGED IN VLR、UNKNOWN或无SGSN NUMBER字符串中的第一行
::genteman - 2009-09-22 -CMD@WinXP Pro
::contact amdaround@163.com
::错误处理部分借用了Will Sort的代码,在此表示感谢!
@echo off & setlocal enabledelayedexpansion
if [%1]==[:error] goto :error
if [%1]==[] %0 :error 0 "Incomplete argument - Usage:%~n0 <filename>"
if not exist "%~1" %0 :error 1 "%~n1 does not exist"
for /f "delims=" %%i in (%~s1) do (
echo "%%i" | find "hgsdp" >nul && set tmpstr=%%i
set str=!str!,%%i
if %%i==END (
echo "!str!" | find "SGSN NUMBER" >nul || echo !tmpstr! >>"%~dp1NO SGSN NUMBER.txt"
echo "!str!" | find "MS PURGED IN SGSN" >nul && echo !tmpstr! >>"%~dp1MS PURGED IN SGSN.txt"
echo "!str!" | find "MS PURGED IN VLR" >nul && echo !tmpstr! >>"%~dp1MS PURGED IN VLR.txt"
echo "!str!" | find "SGSN NUMBER,UNKNOWN" >nul && echo !tmpstr! >>"%~dp1"UNKNOWN.txt
set str=
)
)
goto :EOF
:error - 错误处理
echo.
echo Error %2: %3
echo.
exit /b %2
现在的问题是运行效率特别低,对一个大小超过10M的文件处理需要至少24小时的执行时间,如果是在UNIX下用sed来处理的话只需要几秒钟就能搞定。