LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   where is search tool in Linux ? (https://www.linuxquestions.org/questions/linux-desktop-74/where-is-search-tool-in-linux-497369/)

lomnhom 10-31-2006 07:09 PM

where is search tool in Linux ?
 
I use fedora core and I like to find a tool that allow me to search file that contain a given string. Any help is welcome.

Thank you.

hockeyman_102 10-31-2006 07:15 PM

>updatedb
>locate filename

don't get worried if 'updatedb' takes a while - it creates the database so locate will actually work.

truthfatal 10-31-2006 08:06 PM

find -> http://linux.about.com/od/commands/l/blcmdl1_find.htm

slocate -> http://linux.about.com/library/cmd/blcmdl1_slocate.htm

bigrigdriver 10-31-2006 08:43 PM

If the string is in the file name, use

find /etc -name '*.*' -type f -regex 'string'

where /etc is the directory to search, -name '*.*' is the filename unspecified (wildcards), -type f is regular file (see man find for other file types), and -regex 'string' is the string in the filename.

If you want to find 'string' inside the file, not in the filename, use

find /etc -name '*.*' -type f | xargs grep 'string'

where /etc, -name, and -type are explained above, | is the pipe symbol (pipe the output of find through another command), and the other command is grep to find the 'string' inside the file.

However, it the 'string' is in the filename, a much faster way to find the file is to use the locate command. Locate uses a database of all filenames on the system. The database is built using the updatedb command, which must be run as root.

So, su to root and run updatedb to update the database of filenames, then run locate 'string' (without quotes) to find the filenames with the 'string' in the filename.

jschiwal 10-31-2006 09:23 PM

If it is the contents of files that you are interested in, consider installing the beagle package. There is a KDE tool called "kerry" that brings up a search dialog. It will search documents and pdf files. I've found it as useful as google at times.

rickh 10-31-2006 10:05 PM

There is a new program called searchmonkey. Just made it into Debian Sid, but it's probably generally available. Supposed to replace "grep" and "find"


All times are GMT -5. The time now is 11:52 PM.