Batch scripting find the first occurence of string taskid [duplicate]

南楼画角 提交于 2019-12-13 09:47:57

问题


I have a text file with a string occurs multiple lines. I want to get the line where this is the first occurrence of the string. I could find all occurrences using below command but I want only first occurrence in single line command.

findstr /C:"taskId" Book.txt

Book.txt

3047 [main] INFO  com.informatica.saas.utilities.task.ICSTask  -
Submitted run of the task: taskId=0015FL0Z0000000000R6,
taskRunId=20869
https://use4.dm-us.informaticacloud.com/saas/api/v2/activity/activityMonitor
https://use4.dm-us.informaticacloud.com/saas/api/v2/activity/activityMonitor
https://use4.dm-us.informaticacloud.com/saas/api/v2/activity/activityLog?taskId=0015FL0Z0000000000R6&runId=20869

回答1:


Try something like this:

for /f "delims=" %%a in ('findstr /C:"taskId" Book.txt') do (
   echo %%a
   goto :continue
)
:continue



来源:https://stackoverflow.com/questions/59062749/batch-scripting-find-the-first-occurence-of-string-taskid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!