免费程序在Windows中grep unicode文本文件?

jac*_*see 7 windows unicode grep

我有一个unicode文本文件的集合(从regedit导出),我想拉出所有带有特定文本的行.

我已经尝试过Grep for Windows和findstr,但两者似乎无法处理unicode编码.我的结果是空的,但是当我使用-v选项(显示不匹配的行)时,输出在每个字符之间显示NUL.

是否有任何免费选项可以在Windows中对Unicode文件执行简单的grep?

Joe*_*oey 10

好吧,虽然findstr无法直接处理Unicode文件,typefindstr实际上并没有问题地处理Unicode 输入.

所以你需要做的就是

type myfile.txt | findstr /c:"I'm searching for this"
Run Code Online (Sandbox Code Playgroud)
> type uc-test.txt
Unicode test. äöüß
Another line
Something else
> findstr "Something" uc-test.txt

> findstr /v "Something" uc-test.txt
 ?U n i c o d e   t e s t .   õ ÷ ³ ?
 A n o t h e r   l i n e
 S o m e t h i n g   e l s e
> type uc-test.txt | findstr "Another"
Another line

  • 谢谢,我确实做到了这一点:`FOR/R %% D IN(*.txt)输入"%% d"| findstr/c:"搜索文本">> outFile.txt`(现在我想找出一种方法为每行添加前缀文件的名称和/或时间戳,类似于grep的默认行为.) (2认同)

jac*_*see 9

刚刚遇到grepWin,它非常适合我想要的东西.希望我早点发现它!