FINDSTR in Command Prompt

十年热恋 提交于 2019-12-25 03:41:06

问题


I am trying to generate a file with all of the rows from an input file containing a certain string using the FINDSTR commanand in cmd.exe. My command below does not produce any results, whereas the FIND command (also below) shows that there are 182,688 rows containing the string I'm looking for...

FIND command:

FIND /c "searchstring" c:\Users\karl\Desktop\Report.csv

gives the following:

---------- C:\USERS\KARL\DESKTOP\REPORT.CSV: 182688

FINDSTR command:

findstr /i /c:"searchstring" c:\Users\karl\Desktop\Report.csv > results.out

gives me a blank file called results.out.

What am I missing?


回答1:


FINDSTR has many undocumented "features" that could be tripping you up. See What are the undocumented features and limitations of the Windows FINDSTR command?

You have not told us what your search string is, so I can't be sure. But your problem is probably related to one or more of the following:

  • Special rules for escaping " and \ within literal search strings
  • Many extended ASCII characters do not find themselves when used in command line search strings.
  • FINDSTR cannot search unicode files. I am told that FIND can search unicode files.



回答2:


Try this one. the /n gives a line number:

findstr /i /n "\<searchstring\>" c:\Users\karl\Desktop\Report.csv



来源:https://stackoverflow.com/questions/15278902/findstr-in-command-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!