Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

findstr

Status
Not open for further replies.

olblue

Technical User
Jan 14, 2004
2
US
I have a simple string as follows:

findstr /c:"error" acstest.x >reason.txt

what I am attempting is once the error is found I need to step back 3 lines to show the reson for the error.

So my question is how can I step back 3 lines and display the reason code... please bear in mind that the file could have many errors and the file could be very large..

the foot print of the error is as follows:

reason =xxx

data

error

then it repeats over and over again.
 
I've used grep for that:
(snip from a windows batchfile)
Code:
rem report 23 lines before a fail
%_UTIL%\grep -i -n -h --before-context=23 -E "failed|error" "%_LOG%" >>"%_LOG%.err"

Get grep using google
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top