小弟不是很懂所以来问问。
原LOG如下:
--------------------------------------------------------------------------------------------------------------
……
BTS ALARM HISTORY LISTING
<HIST> BSC455 BCF-0440 BTS-0440 QUAL 2016-03-15 08:19:30.72
*** ALARM DESHENGHUABY1
ENABLED
(38348) 7767 BCCH MISSING
<HIST> BSC455 BCF-0440 BTS-0441 QUAL 2016-03-15 08:19:30.92
*** ALARM DESHENGHUABY2
ENABLED
(38349) 7767 BCCH MISSING
<HIST> BSC455 BCF-0440 BTS-0442 QUAL 2016-03-15 08:19:31.12
*** ALARM DESHENGHUABY3
ENABLED
(38350) 7767 BCCH MISSING
……
END OF BTS ALARM HISTORY LISTING
COMMAND EXECUTED
BTS ALARM HISTORY LISTING
<HIST> BSC451 BCF-0373 BTS-0373 QUAL 2016-03-15 08:27:31.50
... CANCEL DONGYIGUOJISF
DISABLED
(36699) 7767 BCCH MISSING
END OF BTS ALARM HISTORY LISTING
……
--------------------------------------------------------------------------------------------------------------
我写的代码:- @echo off
- for /f "tokens=1-4 delims=/-周 " %%i in ('date /t') do set Date=%%i-%%j-%%k
- (findstr/n "\<QUAL\>" "%Date%".log)>C:\Users\Administrator\Desktop\日志\"%Date%".txt
- exit
复制代码 提出来的txt是这样的
221: <HIST> BSC455 BCF-0440 BTS-0440 QUAL 2016-03-15 08:19:30.72
227: <HIST> BSC455 BCF-0440 BTS-0441 QUAL 2016-03-15 08:19:30.92
233: <HIST> BSC455 BCF-0440 BTS-0442 QUAL 2016-03-15 08:19:31.12
674: <HIST> BSC451 BCF-0373 BTS-0373 QUAL 2016-03-15 08:27:31.50
但我不想要字符为 CANCEL 的上一行数据。就是674这行的数据删除掉,怎么能实现?
我在论坛搜索了这个代码想把CANCEL 那一行删除掉再执行上面的代码,但是他把前面的数据也删除了。如下:- @set @n=0;/* & echo off
- dir /b *.log|cscript -nologo -e:jscript "%~0" "%Input%"
- exit/b & rem */
- arg = WScript.Arguments(0);
- fso = new ActiveXObject("Scripting.FileSystemObject");
- while (!WSH.StdIn.AtEndOfStream) {
- f = WSH.StdIn.ReadLine();
- txt = fso.OpenTextFile(f,1).ReadAll();
- txt = txt.replace(/QUAL[\s\S]*CANCEL/ig,"");
- fso.OpenTextFile(f,2).Write(txt);
- }
复制代码 我只想实现这样的,帮帮忙啊:
221: <HIST> BSC455 BCF-0440 BTS-0440 QUAL 2016-03-15 08:19:30.72
227: <HIST> BSC455 BCF-0440 BTS-0441 QUAL 2016-03-15 08:19:30.92
233: <HIST> BSC455 BCF-0440 BTS-0442 QUAL 2016-03-15 08:19:31.12 |