Quick search for text in files in a directory in unix?

Is there a good search solution similar to

find . -name "*.*" | xargs grep "some text"

but with a much faster search, due to offline indexing. Support for wildcards or lightweight regular expressions would be nice, but even finding raw text that could work very quickly due to autonomous preprocessing would be great.

+2
source share
5 answers

, Beagle . , , , beagle-query.

+1

,

grep -rl "string" /path
+1

Recoll , .

0

grep -Ri --include = "*. xml" TEXT/directory/

  • "" xml , , .
0

Python

from __future__ import print_function
import glob
for name in glob.glob('*.*'):
    with open(name,'r') as aFile:
        for n, text in enumerate(aFile):
            if 'some text' in text:
                print( name, n, text )

re.

Instead of printing the results, you can create a database shelveor other index structure.

-3
source

All Articles