Find a files that containing particular text in Linux

Once upon a time, we want to find a files that just containing particular text. Unfortunately, we have 10000 files inside our folder. Should we check one by one? yes, you should. Until you find a better way to solve this issue :). For me, it was happened when I stored my configuration files into one folder, there are about 50+ files and I just want to know where are my files that I need. I do not want to ruined my time with opening files one by one. After a little googling, I found a better way to solve this. You can just using :

grep -H -R “string that we want to search” /path/to/directory | cut -d: -f1

voila, you get the file that you need 🙂

Write a Comment


This site uses Akismet to reduce spam. Learn how your comment data is processed.