Saturday, November 1, 2014

Find-like and Grep-like Tools in Windows

Search by File Name

  • open CMD.exe
  • use command (more info): dir *.class *.java /b/s

Search by File Content

  • open CMD.exe
  • use command:
    findstr /s /i mock *.java *.groovy
  • what it does:
    • search not only in the current directory but also in subdirectories (/s)
    • searches for the string "mock", ignoring the case (/i)
    • in all .java and .groovy files
  • to find a string "pink rose", do:
    findstr /s /i /c:"pink rose" *.java *.groovy
    Without the "/c:", you will get all occurances of pink and rose.
  • option /r allows to use regular expression, np.:
    findstr /i /r /c:"references .*\.country" *
  • more info
(tested in win7)

No comments: