Sivo 悉见

grep in Windows(Windows用grep命令的方法)

匿名 · 更新于 2013/12/8

总结一下Windows用grep命令的方法:

0.       下载并安装 unxutils.exehttp://gnuwin.epfl.ch/apps/unxutils/en/index.html)即可在cmd里使用grep。基本满足我的需求。
1.       安装并配置Cygwin (http://www.cygwin.com),在选择安装组件的时候选中grep即可。安装完成后,记得把<path>/Cygwin/bin目录添加至PATH变量。
2.       第三方厂商为Windows平台开发的grep:PowerGREP (http://www.powergrep.com)或Windows Grep (http://www.wingrep.com)。收费的,找破解麻烦~
 
下面我来举个简单的例子:我想查询位于当前目录下的test.txt文件中的test,通过grep我可以轻松快速地完成这项任务,命令如下:
 
grep "test" test.txt