FINDSTR Grouping Search Text

Microsoft Windows 2000 terminal server w...
March 17, 2010 at 02:40:11
Specs: 2000
Hi I have a log file and I want to return those
phrase that don't match.

I am using /g: but the issue I have is the
phrase I am using is 6 lines long.. And I don't
know how to get FINDSTR to search for the 6
lines together.

The aim is to isolate those logs which have
failed, but the only indication of failure is the
first 2 lines appear rather than the whole 6

I wish to output the results into a separate text file > test123.out or whatever.

Any suggestions please? Thanks very much.

See More: FINDSTR Grouping Search Text

Report •

March 17, 2010 at 03:25:09
AFAIK findstr, like find, is line oriented. That is, it does it's thing one each line.

If you post a meaningful chunk of the file maybe something can be hammered out.

Helping others achieve escape felicity


Report •

March 17, 2010 at 07:41:16
If the file you're looking at is either 2 lines long or 6 lines long, it shouldn't be hard to just check the file size.

Report •

March 17, 2010 at 09:10:31
There's no easy way to check if a multi-line text block appears in a file or not ...

So, the best you can do is to perform one or more tricks. Like Razor says, would it be good to check on the number of lines ? (in other words, can you come to a conclusion ONLY by means of checking the number of lines)

I guess not ... so, what you can also do, is to perfom 6 checks, and only if all checks are OK ...

.... but, then there is no way to tell that those lines are all part of a block. They may be anywhere in the files. But, this depends on the condition, this has got a much better chance of being sort of correct.

If you really need to check if all the lines match, as a block, I would do this :

- find the line number(s) of line nr.1 (of the block) that matches
- for each occurance, advance one line, and check if this line matches line 2 of the block
- repeat (for each occurance still) until line 6

This is basically the way it would be done if there was a tool already, only you will need to write it.

Report •

Related Solutions

Ask Question