windowscmdfindfile-search

Windows equivalent of Unix "find" command?


I'd like to be able to search files on a Windows machine using the command line instead of the GUI interface. For example, on Linux, I use:

find . -name "*.c" -exec grep -Hn "sqlcommand" {} \;

Is there something similar with Windows?


Solution

  • After long time working with Unix systems I had to make some scripts on Windows. For serious scripting Powershell is the tool you should use. You can search Internet with keywords like powershell find string in file, or other combinations and you find a lot of information. That's the problem, a simple oneliner like

    get-childitem C:\yourdir -include *.c -recursive |Select-String -pattern sqlcommand
    

    won't help you much. You need to find the PowerShell IDE, learn the different syntax and try to love / accept that new stuff.

    Prepare for a study with PowerShell when you want to do these things more often, or try to get a Unix-like environment on your windows (cygwin, or better git for windows)