-   Linux - Newbie (
-   -   Find in files on linux? (

neocookie 12-16-2005 07:45 AM

Find in files on linux?
Hi all

Is there any way I can search the whole linux file structure to look for a specific string in a file? I've lost something and can only remember the title I added.


vls 12-16-2005 08:30 AM

grep will do what you need.

Are you sure you need to search the entire file system?

Did you create the file as a regular user (not root)? If so, the only place the file could be is in your $HOME or /tmp.

Try "grep -R -F 'string to find' $HOME/*"
"grep -R -F 'string to find' /*" if you have to search the whole system.

neocookie 12-16-2005 08:41 AM

Thanks. I'll give that a go.

saikee 12-16-2005 09:44 AM

Never use grep yet but to find from "/" by naming the filename I always use

find / -name filename

pixellany 12-16-2005 10:18 AM


Originally Posted by saikee
Never use grep yet but to find from "/" by naming the filename I always use

find / -name filename

OP wants to find a string IN a file....

The Gnome search tool has an option for searching in file contents.

saikee 12-16-2005 11:45 AM

You are right I was caught out by the words

whole linux file structure

JimBass 12-16-2005 09:08 PM


grep -e {string searched for} [locations to Search]
For example, if you created this file as a regular user, chances are good that it would be in home, as you don't have write permissions in many other places. If you wanted to find files with the word "drumstick" in them (title or contents), and you wanted to look in your home directory and all subdirectories, you would look for:


grep -e drumstick ~
If you knew drumstick was in the file name, then the find command with wildcards would be signifigantly faster. That command would look like:


find ~ -name *drumstick* -print
~ = /home/{username}, just a good shortcut. If you wanted to search the entire filesystem, then it becomes

find / -name *drumstick* -print
but you would need to do that as root, as it will spit some errors if you try to look in places where you don't have permissions to read.


All times are GMT -5. The time now is 10:44 PM.