• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Find all Files Containing a String in Linux

Written by Rahul, Updated on March 18, 2017

How to Find all Files Containing a String in Linux. This tutorial will help you to search all files containing specific text string recursively. This tutorial uses “find” command to search string in files. Alternatively, You can also use grep command to search text.

Command:-


# find / -exec grep -l “string-to-search” {} ;


Uses:

Below is an example command which searches text ‘redhat’ in / filesystem. This command will search for all files containing string ‘redhat’ and list file names only like below.

# find / -exec grep -l "redhat" {} ; 

/lib64/security/pam_oddjob_mkhomedir.so
/lib64/libdevmapper.a.1.02
/lib64/libdevmapper-event.a.1.02
/lib64/libdevmapper.a
/lib64/libdevmapper-event.a
...

To Search in specific file extension files. Like search ‘redhat’ in all php files only, use following command.

# find / -name '*.php' -exec grep -l "redhat" {} ; 

/var/www/projects/index.php
/var/www/projects/new.php
...

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy