Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 检查两行之间的行是否为空(字符串)_Batch File - Fatal编程技术网

Batch file 检查两行之间的行是否为空(字符串)

Batch file 检查两行之间的行是否为空(字符串),batch-file,Batch File,谢谢 我有一个日志文件,其中包含如下命令结果(模式) 我正在尝试获取之间有空行的服务器列表(打开/关闭到模式的连接) 到目前为止,我能够做到这一点,只得到结果文件的最后一个条目 代码: @ECHO OFF setlocal ENABLEDELAYEDEXPANSION color 9E title Tool SET "sourcedir=C:\Logs\" SET "destdir=C:\Logs\" for /f "tokens=1 delims=[]" %%a in ('find /n "O

谢谢

我有一个日志文件,其中包含如下命令结果(模式)

我正在尝试获取之间有空行的服务器列表(打开/关闭到模式的连接)

到目前为止,我能够做到这一点,只得到结果文件的最后一个条目

代码:

@ECHO OFF
setlocal ENABLEDELAYEDEXPANSION
color 9E
title Tool
SET "sourcedir=C:\Logs\"
SET "destdir=C:\Logs\"
for /f "tokens=1 delims=[]" %%a in ('find /n "Opening connection to"^<"%sourcedir%\Results.log" ') do set /a start=%%a
for /f "tokens=1 delims=[]" %%a in ('find /n "Closing connection to"^<"%sourcedir%\Results.log" ') do set /a end=%%a
(
for /f "tokens=1* delims=[]" %%a in ('find /n /v ""^<"%sourcedir%\Results.log" ') do (
 IF %%a geq %start% IF %%a leq %end% ECHO(%%b
 )
)>"%destdir%\FailedList.log"
GOTO :EOF

当输入数据具有示例数据的模式时,此代码将获得所需的输出:

@echo off
setlocal EnableDelayedExpansion

set "ip="
(for /F "tokens=1,5" %%a in (Results.log) do (
   if "%%b" equ "!ip!" echo !ip!
   set "ip=%%b"
)) > FailedList.log

当输入数据具有示例数据的模式时,此代码将获得所需的输出:

@echo off
setlocal EnableDelayedExpansion

set "ip="
(for /F "tokens=1,5" %%a in (Results.log) do (
   if "%%b" equ "!ip!" echo !ip!
   set "ip=%%b"
)) > FailedList.log

谢谢你,阿奇尼。这对我来说太完美了,谢谢你。那对我来说太完美了。
@echo off
setlocal EnableDelayedExpansion

set "ip="
(for /F "tokens=1,5" %%a in (Results.log) do (
   if "%%b" equ "!ip!" echo !ip!
   set "ip=%%b"
)) > FailedList.log