user1539144
user1539144

Reputation: 1

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"

Upvotes: 0

Views: 1272

Answers (1)

wmz
wmz

Reputation: 3685

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

Upvotes: 1

Related Questions