如何在cmd中的变量中存储命令的输出? [英] How to store output of command in variable in cmd?
本文介绍了如何在cmd中的变量中存储命令的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在批量编程中将命令的输出存储在变量中,请提前帮助我.
就像我想将find命令的输出存储在变量p中设置p =查找/c"chi *""file.txt"
解决方案
假定您要存储行数而不是find产生的输出的全行
对于/f"tokens = 3" %% i在('find/c"chi *""file.txt"')中的 确实设置了p = %% i
注意:要存储完整行,可以使用 tokens = *
或 delims =
(等号后没有空格!).
i want to store output of command in variable in batch programming please help me..thanks in advance..
like i want to store output of find command in variable p set p=find /c "chi*" "file.txt"
解决方案
Assuming you want to store number of lines and not full line of output produced by find
for /f "tokens=3" %%i in ('find /c "chi*" "file.txt"') do set p=%%i
Note: to store full line you can use either tokens=*
or delims=
(no space after equal sign!).
这篇关于如何在cmd中的变量中存储命令的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文