开发者

Howto: Searching for a string in a file from the Windows command line?

开发者 https://www.devze.com 2023-04-12 09:06 出处:网络
Is there a way to search a directory and its subdirectories\' files for a string?The string is rather unique.I want to return the name of the string and hopefully the line that the string is on in the

Is there a way to search a directory and its subdirectories' files for a string? The string is rather unique. I want to return the name of the string and hopefully the line that the string is on in the file. Is there anything b开发者_如何学JAVAuilt into Windows for doing this?


You're looking for the built-in findstr command.

The /S option performs a recursive search.


There is the find.exe command, but it's pretty limited in its capabilities. You could install Cygwin or Unxutils and use a pipeline including its Unix-style find and grep:

find . -type f | xargs grep unique-string
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号