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
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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.
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?
Here's a Powershell solution:
gci -r $SomePath -filter "*.cpp","*.h" | Select-String $FindThisString
gci is for recurse, and of course is optional, as are the two file extension filters. A useful parameter of
-list which will only report the first instance of a match in a file, instead of giving you each occurrence of it per file.
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:
gci -r $SomePath -filter "*.cpp","*.h" | Select-String $FindThisString -list | ii
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. :-)
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!
grep implementation for Windows by the famous tortoise svn developers:
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.
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.
Total Commander (with app named Everything) has option to search in files (Alt+F7). Everything speeds up the process of finding files and then TC looks into each file. Wildcards for files and RegExp for text are allowed.