DOS batch command to read some info from text file

后端 未结 5 1050
醉话见心
醉话见心 2021-01-19 03:16

I am trying to read some info from a text file by using windows command line, and save it to a variable just like \"set info =1234\"

Below is the content of the txt

5条回答
  •  余生分开走
    2021-01-19 03:58

    Here's a one line version:

    for /f "tokens=2" %%i in ('findstr Revision: input.txt') do set revision=%%i
    
    1. findstr is used to filter the file. It will print "input.txt:Revision: 1234"
    2. Then the "tokens=2" means that we are interested in the second token, "1234". By default for breaks on white space.

提交回复
热议问题