Technically, find and findstr aren't part of PowerShell, though they are
likely found on any machine capable of running PowerShell.
If you're already familiar with grep, I suggest installing that. Sourceforge
has a great project which has a number of GNU apps compiled for windows.
http://gnuwin32.sourceforge.net/packages.html
Mike
"swyck" <axlaim@xxxxxx> wrote in message
news:1f4615c1-1706-4f45-bf82-5f91a414deef@xxxxxx
Quote:
> i've been using FIND and FINDSTR to search through logs or piped
> output. It is often compared to the Unix GREP command and I think it
> works pretty well.
>
> However, one feature that I've loved with GREP that is missing from
> FIND or FINDSTR is the GREP -B switch which prints x lines prior to
> the matching line, and -A which prints x lines after the matching
> line.
>
> For example say I'm parsing a large log file, and I am searching on
> an error message. There may be an explanation of why the error
> occurred on the line before (or after) the line with the error
> message. That description may not have anything in particular that
> can be searched on, or I may not know what it is. With the GREP
> switch I can output my match, but I can also include the lines that
> give me the information I need.
>
> That's just one example, but there are plenty others. Is there a
> relatively simple command I can run that will do the same thing in
> Powershell?