Windows命令行在文件中搜索匹配的字符串

在Linux系统中我们使用grep命令,而在windows系统可以使用findstr

findstr

Examples

findstr "computer help" myfile.txt

In the above example, any lines containing "computer help" would be printed to the screen.

findstr /s "computer help" *.txt

Similar to the first example, the above example would find any lines containing "computer help" in any txt file in the current directory and all sub directories

findstr /x /c:"computer help" *.txt

Match .txt files that contain an exact match on "computer help"; therefore, files that contain "computer helps" or other non-exact matches will not be displayed. It is important to realize that using /x must be a line that exactly matches "computer help"; in other words, if anything else is on the same line, it's not an exact match.

findstr /n /i /c:"computer help" *

Search for any file containing "computer help" regardless of its case and display the line where the text is found.

参考: http://www.computerhope.com/findstr.htm


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值