piping findstr's output
Posted
by Gauthier
on Stack Overflow
See other posts from Stack Overflow
or by Gauthier
Published on 2010-04-29T12:07:42Z
Indexed on
2010/04/29
12:37 UTC
Read the original article
Hit count: 532
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"
© Stack Overflow or respective owner