从命令行获取输出并保存到变量中 [英] Get output from command line and save into variable
本文介绍了从命令行获取输出并保存到变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行以下命令,仅获取第二行并将其放入批处理文件的变量中以进行字符串比较
I am trying to run the following command and get only the 2nd line and put it into a variable in a batch file for a string comparison
wmic baseboard get product
这将输出以下
Product
20BUS0YN00
我只想要第二行
这是我正在尝试的方法,但随后得到第一行和空白行
This is what I am trying, but it gets the first line and the blank line afterwards
for /f %%i in ('wmic baseboard get Product') do set VAR=%%i
推荐答案
for /f "tokens=2 delims==" %%i in ('wmic baseboard get Product /value') do set VAR=%%i
这篇关于从命令行获取输出并保存到变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文