1

Say, I have many documents in my computer and I just want to find one document which contains some specific word(s) in it. I can't even remember the type or name of the document.

I tried to achieve this with Unity (Documents & folders) lenses, but it seems Ubuntu only looking for the names (of files and folders) but not looking inside of the documents.

Please advise whether I can achieve my goal using Ubuntu or not.

2
  • 1
    I don't know about a Unity lens, but it would be fairly easy to write a script to do this, but it would potentially take a long time to run--as it would be opening every file and scanning word by word. Useful for finding one file you lost but not very practical for daily use. Jun 2, 2012 at 7:13
  • very much time and resource consuming. It needs to index all files on Hard Drive. Jun 2, 2012 at 9:15

2 Answers 2

2

I recommend to install and use Recoll Lens:

Recoll is a full text search desktop tool which indexes the contents of many file formats including OpenOffice, MS Office, PostScript, MP3 and other audio files, JPEG and more. Besides regular searches, Recoll also lets you perform some advanced operations like searching for the author, file size, file format as well as operators like "AND" or "OR".

Unity Recoll Lens lets you use Recoll from Dash, without having to open any additional GUI. The lens comes with a few filters like Text, Spreadsheet, Presentation, Media or Message, but for more advanced searches, you'll have to manually enter the Recoll search query. Examples: author:"john doe" metallica OR megadeth /2007 (all documents from 2007 or older) dir:/path/to/dir (filters content from /path/to/dir directory).

2
  • Why this is not made available in Ubuntu software centre?
    – DUKE
    Jun 2, 2012 at 11:16
  • do you know of an alternative to Recoll? The developer said that it won't continue support for the lens/scopes, the recoll app is still under development, just not the lens/scope
    – Felipe
    Jan 12, 2016 at 20:46
0

If the text is stored as plain text inside the document file (whether or not the file itself is composed entirely of plain text), then you can search for it from the command-line with a recursive grep. This doesn't require indexing first, but searching through all your files takes a very long time so if you ever have to do this more than a couple of times for your whole disk, you should use an indexing search utility instead (like in this answer).

  1. Open a Terminal window (Ctrl+Alt+T).

  2. Change directory to the top of whatever you want to search. For example, to search everything in your home directory, do cd ~. To search everything on your machine, do cd /. To search everything in an external drive called DocDrive do cd /media/DocDrive. If a directory has spaces in its name, enclose it in quotes (e.g., cd '/media/Documents Drive'.

  3. Run a recursive grep as follows:

    grep -Rs 'word or phrase you are looking for' .

Alternatively, you can skip step 2 and, instead of cding to the folder you want to look inside, replace the . in step 3 with the name of the folder you want to look inside.

If you want to search through all files including those you don't ordinarily have access to, you can run grep as root with sudo:

sudo grep -Rs 'word or phrase you are looking for' .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .