I have a text file that looks like this
number 1 some junk goes here fruit: apple number 2 some stuff goes here fruit: banana number 3 some stuff goes here fruit: orange
My script looks like this
@echo off setlocal EnableDelayedExpansion set input_file=testfile.txt for /f "tokens=2" %%a in ( 'findstr " 1 2 3" %input_file%' ) do echo %%a for /f "tokens=*" %%b in ( 'findstr "fruit" %input_file%' ) do echo %%b
My current code is giving me this
1 2 3 fruit: apple fruit: banana fruit: orange
How do I get the output formatted like this?
1 fruit: apple 2 fruit: banana 3 fruit: orange
Thanks in advance.