I already know the obvious answer to this question: ‘just download <insert favorite windows grep or grep-like tool here>’. However, I work in an environment with strict controls by the local IT staff as to what we’re allowed to have on our computers. Suffice it to say: I have access to Perl on Windows XP. Here’s a quick Perl script I came up with that does what I want, but I haven’t figured up how to set up a batch file such that I can either pipe a command output into it, or pass a file (or list of files?) as an argument after the ‘expression to grep’:
perl -n -e 'print $_ if (m![expression]!);' [filename]
How do I write a batch script that I can do something like, for example:
dir | grep.bat mypattern grep.bat mypattern myfile.txt
EDIT: Even though I marked another ‘answer’, I wanted to give kudos to Ray Hayes answer, as it is really the ‘Windows Way’ to do it, even if another answer is technically closer to what I wanted.
I wrote this a while back: