Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 51719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:47:40+00:00 2026-05-10T16:47:40+00:00

I already know the obvious answer to this question: just download <insert favorite windows

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:47:41+00:00Added an answer on May 10, 2026 at 4:47 pm

    I wrote this a while back:

    @rem = '--*-Perl-*-- @echo off perl -x -S %0 %* goto endofperl   @rem -- BEGIN PERL -- '; #!d:/Perl/bin/perl.exe -w #line 10 use strict;  #use Test::Setup; use Getopt::Long;  Getopt::Long::Configure ('bundling');  my $ignore_case    = 0; my $number_line    = 0; my $invert_results = 0; my $verbose        = 0;  my $result = GetOptions(      'i|ignore_case' => \$ignore_case,      'n|number'      => \$number_line,     'v|invert'      => \$invert_results,     'verbose'       => \$verbose, ); my $regex = shift;  if ( $ignore_case ) {      $regex = '(?i:$regex)'; } $regex = qr/$regex/; print '\$regex=$regex\n'; if ( $verbose ) {      print 'Verbose: Ignoring case.\n'                      if $ignore_case;     print 'Verbose: Printing file name and line number.\n' if $number_line;     print 'Verbose: Inverting result set.\n'               if $invert_results;     print '\n'; }  @ARGV = map { glob '$_' } @ARGV;  while ( <> ) {      my $matches = m/$regex/;     next unless $matches ^ $invert_results;     print '$ARGV\:$.:' if $number_line;     print; }  __END__ :endofperl 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question has been asked here before . The accepted answer was probably obvious
I think I already know the answer to this one, but i hope maybe
I think I already know the answer to this but thought I would ask
This might sound like an obvious question, but I'm new to CouchDB, so I
The Disclaimer First of all, I know this question (or close variations) have been
I know a similar question has already been posed on StackOverflow , but it
This may end up being a trivial question - I know I'm going to
There are already questions and answers like this Add Index to Pre-Existing ObjectStore In
I know that there's lot here on already on multiple click events being fired
Preface : I'm looking for an explanation, not just a solution. I already know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.