How to Find a File Containing a "Keyword" in Linux?


How to find a file containing a "keyword" in linux?

To find files which contain a specific word you can use below commands.

Login to Linux server and open a terminal (Applications >> Accessories >> Terminal).

1. 'Find' command

find -name "*pattern*"

It displayed all the files which have the word "pattern" in the filename.

find /home -name "*pattern*"

This will look for the files in the /home directory with "pattern" in the filename.


2. 'Grep' command

grep -H -r "pattern" folder_name

-H : Print the filename for each match.

-r : Read all files under each directory, recursively.

eg: grep -H -r "pattern" /home

This will look for the files in the /home directory with "pattern" in the filename.

Last update:
2016-06-16 01:54
Author:
Sherin George
Revision:
1.1
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Most popular FAQs RSS

  1. I require an additional IPv4 address. What is Bytehouse's ... (87981 views)
  2. The Most Common Problems When Migrating Websites (66436 views)
  3. How do I create a 301 redirect? (55004 views)
  4. Can I Backup Exchange 2010 with My Online Backup ... (53169 views)
  5. Steps to Add Administrator User for Windows Server (48716 views)

Latest FAQs RSS

  1. Steps to set/customize log rotation from plesk (2016-07-25 07:15)
  2. Generate a self-signed SSL certificate - Nginx,CentOS (2016-07-07 02:31)
  3. Procedure re-register Volume Shadow Copy Service(VSS) in a Windows ... (2016-07-05 04:18)
  4. Steps to Install Mcrypt in Plesk (2016-07-01 17:11)
  5. How to Retrieve a Plesk Password in Linux and ... (2016-07-01 17:09)

Regular new KB articles

Check back from time to time for new articles, or if you have any suggestions please feel free to recommend

top