As the title suggests, what's the fastest (accurate) way of finding which lines of which files match a particular string.
Specifically, I'm searching .cpp and .h files.
|
|
Notepad++ has 'find in files' option, which is located in the 'Search' menu.. This will allow you to search multiple files in a folder (you can specify the folder) and will show you the line numbers of each file as well. You can toggle whether subfolders and hidden folders are included in the search, and it will also allow you to search with \t \n etc. and to search with regular expressions if you need. Notepad++ is a Windows programmers editor (not an IDE) and is Open Source too. (i realise that you have most likely heard of notepad++, but I'm just mentioning it here as an option incase you were unaware of this particular feature, and for others who stumble across this thread later on. Cheers :) |
|||||||||
|
|
Agent Ransack works like a charm. Download it here. |
||||
|
|
|
|
||||
|
|
|
On Unix systems people would most likely use grep to do this, so why not use Windows Grep? |
|||
|
|
while doing a localization of some SW I use DocFetcher to search the same strings in previously translated files. It is free and open-source, but needs to create index first. Just try it. :-) |
|||
|
|
|
Here's a Powershell solution:
The Perhaps you want to instantly open each file where a match is found? Well, the following small change to the above is quite useful, depending on what you have your default file association as:
|
|||
|
|
|
Use "strings" provided by M$. They bought some very good utilities from Sysinternals a few years back. Doesn't require installation, just drop it on the box and run it for syntax. Easy to use and GREAT! |
|||
|
|
|
If you are happy on the command line/with Linux. Might I suggest looking at installing a version of grep for windows? cygwin is a fairly handy way to got about that and will give you a full Linux environment, with bash shell and a rxvt terminal. Otherwise if you just want the tools there is gnuwin32 but then you will be stuck with the Windows cmd.exe prompt. Microsoft actually have their own version of the Unix tools as a download, but they seemed fairly slow compared to the gnu ports when I tried them. They also going to scrap them with Windows 8. |
|||
|
|
|
Another |
|||
|
|
|
This is how I search for text strings in the Windows Registry or files on my Windows XP machine. Let's assume I want to find the string "Enterprise" in a plain text file on the c: drive, then write the output to a file called search_result.txt in c:\windows\temp Open a command prompt then type: findstr "Enterprise" c:*.txt > c:\windows\temp\search_result.txt The string you search for is case sensitive. "Enterprise" and "enterprise" will not find the same string. |
|||
|
|