简体   繁体   中英

How to store output of command in variable in cmd?

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!).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM