Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a good free tool out there to search files for matches to a regular expression?

I would like to search all files of a specific extension for matches to this expression: ^ := '([a-z0-9]{3})'$

I would also like it to return (or even better jump to) the line(s) that match.

Anyone know of such a tool?

share|improve this question

5 Answers 5

I think you'd want to do something like this:

find / -name *EXTENSION -exec grep "^ := '([a-z0-9]{3})'$" {} \;

It searches the whole drive (/) for any files ending in EXTENSION and then runs grep with your pattern on that file. You can insert any grep flags in there to get more specific behavior, but by default it prints out the file name with its matching line.

As Dan suggests, you can further combine this with sed to actually manipulate the matching files.

share|improve this answer
    
This will work out of the box if vaccano is running linux. If not, these commands can be run using cygwin. –  Jarvin Jul 9 '10 at 18:02

Also look in to AstroGrep, great little program for going just this.

share|improve this answer

Fastest search tool you will ever see is Everything It does not make index, instead it directly access the NTFS records and find your file without even looking and iterating through your hard drive

It supports regular expression

It is my everytime search tool, it shows the result while you are typing, what can be more faster than that?

share|improve this answer
    
Interesting, but I don't know that my hard disk is big enough to "Download Everything for Windows 2000, XP, 2003, Vista, 2008 and Windows 7" ;-) –  Steve314 Jul 9 '10 at 21:42
    
Looking at the FAQ though - item 1.3 "No, "Everything" does not search file contents, only file and folder names.", which I think means this doesn't answer the question - though the wording of the question isn't clear. –  Steve314 Jul 9 '10 at 21:45
    
Its name often confuses while i tell others about it :P , Yup, i am a poor reader and didn't read the last 2 lines of the question with mind. Anyway it will help a lot in your daily file search tasks –  LifeH2O Jul 11 '10 at 19:37
    
Everything DOES make an index just not a very big one. –  snowdude Jan 25 '12 at 11:09
    
Yes it does make an index, but takes a very little time to do that. –  LifeH2O Jan 1 '13 at 12:30

sed("stream editor") will do it. They have Sed for windows as well as for linux (it should be in your package manager if it isn't already in the default install.

share|improve this answer
    
sed seems an inappropriate answer - it doesn't just find, it modifies. The classic Unix program for regex search is grep, and there are certainly Windows versions around. There will certainly be a version in MSYS - but that's kind of a heavyweight solution if all you want is grep. –  Steve314 Jul 9 '10 at 21:40
    
@Steve314: Perhaps it is an overly complex solution... but it works perfectly fine. Sed can for the most part encompasses all of greps functionality and a whole lot more, for example a basic grep done in sed is: 's/pattern/&/p'`. Nerdling's answer of course is much better because it includes the find statement and everything. –  Jarvin Jul 9 '10 at 23:07
    
I should have read up on sed again before commenting anyway. Based on vague memories, I thought it edited files in-place. Since it actually edits streams (I should have known really - it's in the name) its a much more sensible answer than I thought. –  Steve314 Jul 12 '10 at 19:48

Agent Ransack will do it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.