Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-14-2013, 10:03 PM   #1
LQ Newbie
Registered: Feb 2013
Posts: 2

Rep: Reputation: Disabled
Finding a string in all files in Linux

I would like some help to find a specific word in all the files in Linux. I am looking for the file that has the string "Panasert" in it so that I can edit that. But there are many many files and many many directories. I have spent 3 hours trying to locate this file and could use help with the command I can use to locate this.
Thanks, BJ
Old 02-14-2013, 10:09 PM   #2
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,561

Rep: Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127
Are you looking for a file that has the word "Panasert" in the name, or in the contents?

In the name:
find / -name "*Panasert*"
In the contents:
grep -r Panasert /
Of course if you have any idea what subdirectory it might be in, limiting the search to that directory would SIGNIFICANTLY reduce execution time. For example, if you know the file must be somewhere in "/home", you could do
find /home -name "*Panasert*"
grep -r Panasert /home/

Last edited by suicidaleggroll; 02-14-2013 at 10:12 PM.
Old 02-14-2013, 10:49 PM   #3
Senior Member
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Even you can combine both find and grep:
find / -name "<search_pattern>" -exec grep "<search_string>" {} \;
Old 02-14-2013, 10:51 PM   #4
LQ Newbie
Registered: Feb 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks suicidaleggroll. I did what you suggested and it worked right away. Much appreciated.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
question about finding string in multiples files g_paschoal Programming 4 04-18-2011 11:09 AM
[SOLVED] finding a string in file himu3118 Programming 2 05-10-2010 10:00 AM
Finding Paragraphs that Contain a Search String BlueberryPickles Linux - Newbie 2 07-02-2008 10:36 AM
finding a string jkeertir Linux - Newbie 3 03-28-2008 05:45 PM
finding a dot in a string saavik Programming 2 10-02-2006 10:05 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:23 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration