how to read certain lines in a file

March 12, 2009 at 04:07:48
Specs: Windows XP
I need a script in batch:
Basically, it searches through a text file and finds file entries. The only problem is that each file entry is on multiple lines. For example:

***** *****
Version 333
User: sanapart Date: 2/26/09 Time: 1:49a
Checked in $/jdev/myprojects/oracle/apps/fnd/framework/personalization
Comment: Fix for Bug# 523

***** *****
Version 52
User: Abbna Date: 2/26/09 Time: 1:47a
Checked in $/jdev/myprojects/oracle/apps/fnd/framework/personalization
Comment: Fix for Bug# 523

I need a .bat file to run in Windows. If we can get it to do the following then I can tweak it further:

- Open the input file (let's just call it "in.txt")
- Search for all lines that contain "java"
- If an java entry is found, then echo the Version ,User details and Checkin information that are 2,3 and 4 lines later.

Hopefully the above description is clear.


See More: how to read certain lines in a file

Report •

March 14, 2009 at 00:46:01
you can use a for loop and variable count

here is the PSEUDOCODE:

set c=
for /f "tokens=*" %%a in (test.txt) do (
  if not defined c (
      echo %%a|find/i "java" && set c=1
  ) else (
      echo %%a
      if ++c==4 set c=

Report •

March 15, 2009 at 23:18:59
Thanks for the reply reno

But line "if ++c==4 set c=" is not working as expected.

Variable C is not incrementing can you tell me how to do this step? It is always having the value c=1.

pls help

Report •

Related Solutions

Ask Question