如何通过批处理脚本从文件中获取特定值? [英] How to get a particular value from file by batch script?
本文介绍了如何通过批处理脚本从文件中获取特定值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件abc.txt,其中包含以下内容
I have a file abc.txt which has the below content
3922 [main] INFO com.informatica.saas.utilities.task.ICSTask - Submitted run of the task: taskId=000YKG0N00000000002N, taskRunId=\
我想提取单词000YKG0N00000000002N
并将其存储在变量中以在脚本中进一步使用.
I want to extract the word 000YKG0N00000000002N
and store this value in a variable to use it further in my script.
我尝试使用以下代码:
for /F "tokens=*" %%A in (abc.txt) & for %%A in ("taskId=" "%") do echo Value: %%~A
我得到的错误:
%% A这一次出乎意料
%%A was unexpected at this time
请帮助我解决问题
推荐答案
也许很简单:
@for /f "tokens=2 delims=:," %%i in ('type abc.txt') do @set%%i
echo %taskID%
或者如果令牌根据您的新问题转移:
or if the token shifted as per you new question:
@for /f "tokens=3 delims=:," %%i in ('type abc.txt') do @set%%i
echo %taskID%
这篇关于如何通过批处理脚本从文件中获取特定值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文