windows - piping findstr's output -


windows command line, want search file rows starting with:

# nnn "<file>.inc" 

where nnn number , <file> string.

i want use findstr, because cannot require users of script install ack.

here expression came with:

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

the file search all_pre.txt.

so far good. want pipe command, example more.

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

the result of same output previous command, file name prefix every row (all_pre.txt).

then comes:

findstr: cannot open | findstr: cannot open more 

why doesn't pipe work?


snip of 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 called b)" 

edit: need escape dot in regex also. not issue, worth 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) should same string before character number of times. must include ", right?

you missing trailing \" in search pattern.

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

the above works me.

edit:

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

this updated search string match these lines example:

# 1 "build_flags.inc" # 7 "build_flags.inc" # 11 "build_flags.inc" # 20 "build_flags.inc" # 45 "build_flags.inc(function called b)" 

edit:

to circumvent "bug" in findstr, can put search batch file this:

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

name myfindstr.bat , call that:

myfinsdtr all_pre.txt | more 

you can use pipe , redirection operators usual.

hope helps.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -