escaping quotes in findstr

2019-09-05 21:18发布

What changes need to be made to the following findstr command in order to return a list of all the uses of the exact phrase "port" : " in all the files contained in the directory and subdirectories?

findstr /I "port" : " *  

Obviously, escaping the quotes is necessary, but what specific syntax is required to escape the quotes while still getting the expression to return the expected values?

This is on windows 8.1 using cmd.exe.

1条回答
够拽才男人
2楼-- · 2019-09-05 21:58

you need to escape the double quote, and since your regular expression uses spaces, use the /c switch to pass a search string instead of space separated regexes:

findstr /I /c:"port\" : " *

from here:

multiple Regular Expressions can be separated with spaces, just the same as separating multiple words (assuming you have not specified a literal search with /C) but this might not be useful if the regex itself contains spaces.

查看更多
登录 后发表回答