How to Search Text in Multiple Files in Linux


1. Search text files with the grep tool
2. SearchMonkey
3. Recoll
4. DocFetcher
5. Regexxer


For Linux users, the need to search for words in one or multiple files arises quite often.


There are many different applications that can do a good job for you. Which application will be most suitable for you depends on your needs and preferences. The applications are mainly distinguished by the following characteristics:

  • Command line tools vs. tools with a graphical interface.
  • Whether they are able to search only in text files, or in all commonly used document types.
  • Whether they use indexing or not.


In this article we will introduce you to different types of search applications, so that you can choose the most suitable one for you.


Note: If you are a Mac user, you can take a look at our article How to Search on Mac.



1. Search text files with the grep tool


About the grep tool


The most popular command-line tool for searching text in Linux is grep. It was created more than 45 years ago! Its developer is the American computer scientist Ken Thompson.


Grep can search in all kinds of text files (.txt, .html, .xml, etc.), but cannot search in other types of documents such as OpenOffice files, PDF files and others.


In fact, the grep command is in the top 15 of the most used commands in Linux, according to Hostinger.


Top 15 most used commands in Linux


The utility is supported by the UNIX, Linux, and Mac operating systems.


There is also a Windows alternative to grep called findstr, which you can read more about in our article How to Search Files in Windows 10.



How to use the grep tool


The grep tool is built into the operating system, so you don't need to install it.


The simplest syntax to find a string in a single file using the grep command is:
grep 'searched-word' filename


By default, the search with grep is case sensitive.


Let's gradually add the most useful options to our search.

1. Make the search case-insensitive with the "-i" option:
grep -i 'searched-word' filename

2. Search recursively in all files in a given directory with the "-r" option:
grep -ir 'searched-word' '/directory'

3. Search whole words only with the "-w" option:
grep -irw 'searched-word' '/directory'

4. Print the line numbers in which the searched word was found with the "-n" option:
grep -irwn 'searched-word' '/directory'

5. Search for multiple words syntax:
grep -ir 'word1|word2|word3' '/directory'


Many other useful grep options can be found in the official Grep Manual.



Advantages and disadvantages of the grep tool

Like any software tool, along with the convenience it gives to you, grep has some drawbacks. Let's summarize its pros and cons.


  • Great flexibility through a wide range of options.
  • Works effectively with regular expressions.
  • It is built into the operating system.



  • Cannot search in any other types of documents except text files.
  • Doesn’t have a graphical interface.
  • Difficult reading of long lines of text in the results.
  • Not so powerful for searching in source code, compared to ack.


2. SearchMonkey

SearchMonkey is a free and open source GUI application for Linux OS, which uses the capabilities of the grep tool. SearchMonkey is also available for Windows and Mac users.


In addition to searching in text files, SearchMonkey supports:

  • OpenOffice and LibreOffice files (.odt).
  • Microsoft Office files (.docx).
  • PDF files (.pdf).


The tool can search a directory recursively and returns the file names and the highlighted content that you search.


Go through the following steps to install and use the tool:
1. Install the application with the following command in the Terminal:
sudo apt install searchmonkey
2. Launch the application.
3. Choose the folder to be searched.
SearchMonkey choose a folder to search
4. Check the "Containing" checkbox, enter your search words and press "Enter."
SearchMonkey check containing checkbox to prepare it for search
5. Click on a file from the list on the left pane to see the fragments of text found.
SearchMonkey click on a file to see the passages found


If you want to search a specific directory, click on the “Advanced” tab and choose the desired folder.


In the "Advanced" pane, you can use additional criteria to filter the results such as by the file size, date of last modification, and others.


SearchMonkey use advanced search


With SearchMonkey, you can also use regular expressions in the same way as in the grep tool.


  • Completely free and open source.
  • Lightweight and easy to use.
  • Doesn't use indexing.
  • Many options for refinement of the search.
  • Works with regular expressions.



  • Slow performance, not suitable for big directories.
  • Does not support RTF, Excel (.xlsx, .xls), PowerPoint (.pptx, .ppt), old Word (.doc) and other popular document types.
  • Cannot search for a combination of words that occur in one sentence.
  • Doesn't show all lines from the results in one place, you have to check each file one by one.




3. Recoll

Recoll is a desktop search tool, available for Linux, Windows, and MacOS. The Linux version is free. It can search not only in text files, but also in most common document formats including:

  • OpenOffice and LibreOffice files (.odt).
  • Microsoft Office files (.docx, .xlsx, .xls, .ppt).
  • PDF files (.pdf).
  • AbiWord files (.abw).


By default, Recoll indexes the files on your "home" directory, which can take some time.


Here are the steps to install and use the program:
1. Install Recoll with the command:
sudo apt-get install recoll
2. Launch the application.
3. On the "First indexing setup" window click on "Start indexing now."
Recoll start indexing your files and folders
4. On the "Missing helper programs" message click "OK."
Recoll next step for indexing
5. Type your search terms and press "Enter."


6. From the results list, click on "snippets" to see all text fragments containing the searched words.
Recoll see passages of text found


7. On the "Snippets" window, you see the pages and the lines in which your searched words are found.
Recoll see the pages and the lines containing your search words


If you need to search in a folder outside your "home" directory, go to "File" -> "Special indexing" and click on the "Browse" button to select the desired directory.



  • Free for Linux users.
  • Supports most common document types.
  • Easy-to-use graphical interface.
  • Supports advanced search options.
  • Allows document preview without opening the file.



  • Although the application uses indexing, the searches are relatively slow.
  • Does not support the Word 97-2003 ".doc" format or the PowerPoint ".pptx" file format.
  • Cannot search for a combination of words.
  • You have to click on each result's "snippets" to see the fragments found.



4. DocFetcher

DocFetcher is a free and open source desktop search tool, available for Linux, Windows, and MacOS. In addition to text file formats, it supports almost all of the document formats which you may use:

  • Microsoft Office 97-2003 files (.doc, .xls, .ppt).
  • Microsoft Office 2007-365 files (.docx, .xlsx, .pptx, .docm, .xlsm, .pptm).
  • Microsoft Outlook email files (.pst).
  • OpenOffice files (.odt, .ods, .odg, .odp, .ott, .ots, .otg, .otp).
  • PDF files (.pdf).
  • Rich Text Format (.rtf).
  • AbiWord files (.abw, .zabw).
  • And others.


Here are brief instructions for using DocFetcher:
1. Install DocFetcher with the command:
sudo snap install docfetcher


2. Launch DocFetcher

3. Right-click on the "Search Scope" pane at the bottom left and choose "Create index from"->"Folder."
DocFetcher Linux create an index of files and folders


4. Choose a folder, give a name to the index and click the "Run" button.
DocFetcher Linux choose a folder to search


5. Wait until the index is created. When it is ready, you will see a check mark in the "Search Scope" pane on the left.
DocFetcher Linux see folders that are indexed
6. Type your search words and press "Enter."


DocFetcher Linux type words to search for
7. Click on a file name to see the fragments of the text containing your searched words. You can navigate in the results with the "up" and "down" arrows.
DocFetcher Linux see passages found



  • Free and open source application.
  • It has a portable version.
  • It can search in archive formats (.zip, .7z, .rar, .tar).
  • Offers additional search options – wildcards, similar words, proximity search and others.



  • Creating an index can take a long time for large folders.
  • Cannot perform case-insensitive search.
  • The navigation in the text results is not user-friendly.
  • Cannot search for a combination of words in a sentence.



5. Regexxer


The regexxer application provides rich possibilities for using perl-style regular expressions. It is a free and open source application with a user-friendly graphical interface, created in 2002.


Regexxer is available only for Linux, and you can most easily install it in Debian and Ubuntu.


Here's how you can use Regexxer:

1. Install the application with the command:
sudo apt-get install regexxer
2. Launch the application, select a search folder and make sure the "recursive" checkbox is selected.

3. Click the "Find files" button.
Regexxer start your search


4. Type your search terms in the "Search" box and click the "Find" button.
Regexxer type your search words
5. Use the arrows at the bottom to navigate in the results.
Regexxer navigate the results found
6. In the left pane you can see the number of results found in the corresponding files, and in the right pane, the text containing the searched words.



  • Completely free and open source.
  • Easy to install and use.
  • Simple and intuitive graphical interface.
  • Supports all types of perl-style regular expressions.
  • Highlights the searched words in the results.
  • Doesn't use indexing.



  • Regexxer is slower than other similar applications.
  • Sometimes becomes unresponsive or closes unexpectedly.
  • Cannot search in any other types of documents except text files.
  • Cannot search for a combination of words that occur in one sentence.




I hope you enjoyed this guide to finding text files in Linux.


I am fully aware that many more things can be added for the presented applications, and also that there are many other useful tools in this niche.


Now I would like to hear from you: which of the presented applications is most useful for you? Do you have any problems using these tools? Do you want to add anything else that is important on this topic?


Let me know your thoughts by posting a comment in the comments section below.

About the author
Dimitar Stamenov
Dimitar is a software developer and entrepreneur with over 20 years of experience in software development and online marketing.

Leave a Comment

Your email address will not be published. Required fields are marked *