+5 votes
224 views
Find file containing text in Linux

in Linux / Unix by (552k points)
reopened | 224 views

1 Answer

+3 votes
Best answer

Install and use CatFish to search for text files in Linux

Currently most of the Linux distributions are integrated with a series of GUI tools developed for the action of searching for files , but when a new user or someone without sufficient experience accesses a Linux system, it can be in trouble for this type of actions. One of the best free tools to search files completely in Linux is CatFish, which is based on most of the console tools available for searches such as find, locate, tracker, doodle and more..

When we are system administrators, file search execution is vital in order to perform our work effectively. Developing with Linux systems can be something without more complications for the more experienced but perhaps for newcomers it is an arduous task. Therefore, the CatFish tool will help us graphically find the files we are looking for by different filters.

With CatFish it will be possible to search for files or folders by name, date, between a range of dates, hidden files, and supports the visualization of the files, this is a free software project and uses the GPL v2 license version.
Let's see how to use CatFish to locate files with special text in Linux..

Install and use CatFish to search for text files in Linux

Step 1

CatFish can be installed from the Ubuntu Software Center or from the terminal by running the following command:
 sudo apt install catfish 

image

Step 2

Once CatFish is installed, we access it from the search engine and the first step to take will be to click on the gear icon and activate the “Search in file contents” box: image
Step 3

With this option active, we will go to the terminal and execute the following syntax for searching files with special text:
 find ./ -type f -exec grep -l "text to find" {} \; 
Step 4

In this case we will look for the following:
 find ./ -type f -exec grep -l "TechnoWikis" {} \; 
image
Step 5

In this example, the find command will search for files starting from the current directory, "./", but we can specify the path to search. The "-type f" option tells CatFish to search only for files and exclude directories, also, we can search only for a certain type of files, for example:
 find ./ -type f -iname "* .txt" -exec grep -l "TechnoWikis" {} \; 
image
Step 6

In this case, the -exec option calls the grep tool so that each of the matching files is ready to verify its content, and if the text is in the file, its name will be reflected in the output, thanks to the option -l. It will also be possible to use only the grep tool like this:
 grep -iRl "TechnoWikis" ./ 
image
Step 7

The parameters used are:
-i
Indicates that the uppercase or lowercase text is ignored.
-R
Refers to recursive file processing
-l
Indicates "Show the name of the file, but not the result itself."
Step 8

From the CatFish application itself it will be possible to search for the files with a unique text, for this it is enough to enter the desired text in the upper field and we will see the following: image
Step 9

There we found each match with details such as:
  • First name
  • Exact size
  • File Location
  • Modification date

With this practical tool it will be simple to find files with certain text in Linux.


by (3.5m points)
edited

Related questions

+5 votes
1 answer
asked Nov 2, 2019 in Linux / Unix by backtothefuture (552k points) | 266 views
+3 votes
3 answers
asked May 10, 2019 in Linux / Unix by backtothefuture (552k points) | 335 views
+5 votes
1 answer
asked Oct 16, 2019 in Linux / Unix by backtothefuture (552k points) | 275 views
+3 votes
1 answer
asked Aug 9, 2019 in Guides by backtothefuture (552k points) | 303 views
+3 votes
1 answer
asked Jul 8, 2020 in Android Tutorial by backtothefuture (552k points) | 543 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users