You are not logged in.

#1 28 Jul 2014 07:40

mine75
New Member
Registered: 28 Jul 2014
Posts: 2

CMD batch to search for a string and matching line and print

G'day all CMD Master,

I am looking for a little help here to print out a particular string in a log file.  The data is actually 1 line below the matching line.  I wanna print the data into a new log/text file.

So far, this is the only command that I've tried. I've tried to search online, but couldn't find anything useful.

findstr /n "VA_SC_P_01_IN" c:\Log.txt

Sample log data (Log.txt):
VA_SC_P_01_IN
strg_2.931|1.046|1.662|3.025|2.046|1.140|2.046


Many many thanks in advance.

Offline

#2 28 Jul 2014 08:13

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: CMD batch to search for a string and matching line and print

This uses a helper batch file called `findrepl.bat` (by aacini) - download from:  https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat

Place `findrepl.bat` in the same folder as the batch file or on the path.


findrepl "VA_SC_P_01_IN" /o:1:1 "<log.txt" >"newlog.txt"

Offline

#3 28 Jul 2014 08:21

mine75
New Member
Registered: 28 Jul 2014
Posts: 2

Re: CMD batch to search for a string and matching line and print

Thanks foxidrive.
Will this line work if there are many events (repetitive) w the same string name, and I wish to print all of them?

Offline

Board footer

Powered by