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

  • Home
  • SEARCH
  • 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 756403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:14:27+00:00 2026-05-14T15:14:27+00:00

Windows command line, I want to search a file for all rows starting with:

  • 0

Windows command line, I want to search a file for all rows starting with:

# NNN "<file>.inc"

where NNN is a number and <file> any string.

I want to use findstr, because I cannot require that the users of the script install ack.

Here is the expression I came up with:

>findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9_]*.inc" all_pre.txt

The file to search is all_pre.txt.

So far so good. Now I want to pipe that to another command, say for example more.

>findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9]*.inc" all_pre.txt | more

The result of this is the same output as the previous command, but with the file name as prefix for every row (all_pre.txt).

Then comes:

FINDSTR: cannot open |
FINDSTR: cannot open more

Why doesn’t the pipe work?


snip of the content of all_pre.txt

# 1 "main.ss"
# 7 "main.ss"
# 11 "main.ss"
# 52 "main.ss"
# 1 "Build_flags.inc"
# 7 "Build_flags.inc"
# 11 "Build_flags.inc"    
# 20 "Build_flags.inc"
# 45 "Build_flags.inc(function a called from b)"

EDIT: I need to escape the dot in the regex also. Not the issue, but worth to mention.

>findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9_]*\.inc" all_pre.txt

EDIT after Frank Bollack:

>findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9_]*\.inc.*" all_pre.txt | more

is not working, although (I think) it should look for the same string as before then any character any number of times. That must include the ", right?

  • 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. Editorial Team
    Editorial Team
    2026-05-14T15:14:27+00:00Added an answer on May 14, 2026 at 3:14 pm

    You are missing a trailing \" in your search pattern.

    findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9]*.inc\"" all_pre.txt | more
    

    The above works for me.

    Edit:

    findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9]*\.inc.*\"" all_pre.txt | more
    

    This updated search string will now match these lines from your example:

    # 1 "Build_flags.inc"
    # 7 "Build_flags.inc"
    # 11 "Build_flags.inc"
    # 20 "Build_flags.inc"
    # 45 "Build_flags.inc(function a called from b)"
    

    Edit:

    To circumvent this “bug” in findstr, you can put your search into a batch file like this:

    @findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9_]*\.inc" %1
    

    Name it something like myfindstr.bat and call it like that:

    myfinsdtr all_pre.txt | more
    

    You can now use the pipe and redirection operators as usual.

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to distribute a command-line application written in Java on Windows. My application
i use the command line in windows to compile and then execute my java
I'm in a Windows Command Line and want the parent folder in a variable.
I want to have output of Windows command-line program (say, powercfg -l ) written
Is there a better windows command line shell other than cmd which has better
I am running both maven inside the m2eclipse plugin, windows command line and my
Looking for a better Windows XP command-line interface. The Visual Studio Command Prompt isn't
What's the best way (or tool) on the Windows (Vista) command line to get
How can I write to parallel port through Windows XP command line?
I've got a PHP script which I'm running from a command line (windows) that

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.