Abstract3000
Abstract3000

Reputation: 79

Get specific Token from a line using batch Findstr & /f

so I have a large log file I need to search for a piece of data in, the line in which the data resides isnt always the same so using a Findstr is the only way to get the specific data, but on the other hand I'm not looking for the entire line but rather a specific token, I really am new to this but this is what I have been messing with:

for /f "tokens=12 delims= " %%i in (LogOutput.txt) do (
findstr /c:"W_LPS_DUMPS (Scheduled)  Start time:" >> time.txt
)

I would like to find that specific phrase in the document, gather the 12th token on the line split by spaces, then write that to a txt file called time.txt. Is this possible or am I way off?

Upvotes: 0

Views: 1165

Answers (1)

Squashman
Squashman

Reputation: 14320

You were kind of close. Give this a try.

for /f "tokens=12 delims= " %%G in ('type LogOutput.txt ^|findstr /c:"W_LPS_DUMPS (Scheduled)  Start time:"') do >>time.txt echo %%G

Upvotes: 1

Related Questions