(grep -r) Search for a string in each pdf [closed]

1

In Android 4.4.4 I have the terminal.apk installed.

How to recursively search a tablet for a specific string in each pdf file?

At the beginning I was going to do it with qpython ( listdir , glob ), but I could not distinguish file directories to search for phrases.

They recommended something like

grep -r "manzanas"

previous installation of termux/terminal.apk and I wanted to understand how to use it. .......... PYTHON: at least previous conversion of pdf to text and:

texto=input("cual texto a buscar: ")
texto2=input("2.cual otro string a buscar: ")
texto3=input("3. cual otra cadena a coincidir: ")
texto=texto.lower()
texto2=texto2.lower()
texto3=texto3.lower()
import os
mmm=[]
for (nombredir, dirs, ficheros) in os.walk('/mnt/'): 
    for nombrefichero in ficheros:
        if nombrefichero.endswith('.txt') or nombrefichero.endswith('.py') or nombrefichero.endswith(''):
                reg=nombredir+'/'+nombrefichero
                reg=reg.replace('//','/')
                arch=open(reg,'r')
                try:
                    af=arch.read()
                    af=af.lower()
                    if texto in af and texto2 in af and texto3 in af:
                      p3=nombredir
                      p2=nombrefichero
                      p1=os.path.getsize(reg)
                      tup=(p1,p2,p3)
                      mmm.append(tup)
                except (UnicodeDecodeError,IOError):
                  asd=33
                arch.close()
mmm=sorted(mmm)
a=len(range(5))
if len(mmm)<a:
    a=len(mmm)
for i in range(a):
  print(mmm[i])

I could find something to find up to 3 patterns if and if and get a list of the files. .................. GREP It will have to convert online or with pdf to text app ...... Thanks like that.

    
asked by edgar 02.10.2016 в 01:26
source

0 answers