简体   繁体   中英

How to get values from text file and store it as a variable in batch script?

How can I get the specific value from text file and store it at a variable by using batch scripting?

Eg. (input.txt)

    ============================================================
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    ============================================================
    True
    True
    0000: 56 43 54 23 34 25 33 34  30 30 36 35 30 34 43 60  VRWTF4534024810
    0010: 20 20 20 20 FF FF FF FF  FF FF FF FF FF FF FF FF      ............
    0020: FF FF FF FF FF FF FF FF  FF FF FF FF FF FF FF FF  ................

Any ideas to get " VRWTF4534024810 " from the sample text file?

***I am using Windows 10 64-bits OS

Thanks in advance.

In command line

for /f "tokens=1-26" %a in ('findstr 0000: input.txt') do @echo %r & set var=%r

or in script (double percent)

for /f "tokens=1-26" %%a in ('findstr 0000: input.txt') do @echo %%r & set var=%%r

I guess this will give a better understanding for tokens and delims. :) https://www.computing.net/howtos/show/batch-files-tokens-and-delimiters-for-loops/473.html

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