0

我在 .txt 文件中有此文本

Job Status  : RUN OK (1)
Job Controller  : not available
Job Start Time  : Thu Feb 07 15:13:47 2013
Job Wave Number : 4
User Status : not available
Job Control : 0
Interim Status  : NOT RUNNING (99)
Invocation ID   : not available
Last Run Time   : Thu Feb 07 15:13:53 2013
Job Process ID  : 0
Invocation List : Param_Test_Job
Job Restartable : 0

有没有一种方法可以让我在第 1 行的 () 之间获得数字 1(在 RUN OK 之后)以使用下游的条件逻辑。我正在尝试在批处理文件中实现这一点。

(此编号将始终位于第一行,并且文本“工作状态”也将始终存在)

谢谢你的帮助

4

1 回答 1

2

无论出现哪一行作业状态,这都会起作用。如果 Job Status 出现多次,它将采用最后一次出现的值。

@echo off
for /f "tokens=2 delims=()" %%N in (
  'findstr /bc:"Job Status" test.txt'
) do set "result=%%N"
于 2013-02-08T12:28:17.920 回答