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.

Eliah Kagan
  • 119,640
DUKE
  • 3,388

2 Answers2

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).

Jakob
  • 10,789
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' .
Eliah Kagan
  • 119,640