Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to search for files containing specific word?

share|improve this question
Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words? – dr_willis May 2 '11 at 13:39
up vote 26 down vote accepted

With command line you have several options. The 3 I use the most are...

  1. locate {part_of_word}

    This assumes your locate-database is up to date but you can update this manually with: sudo updatedb

  2. grep as explained by dr_willis. One remark: -R after grep also searched within directories. Example:

    grep -R {something_to_look_for} {where_to_look_in}
  3. find . -name '*{part_of_word}*' -print

Where . is the directory where you are at the moment and * is a wildcard.

Oh and you can also combine these. Example: locate {something}|grep {some_part_of_something}|more

If I recall correctly: locate is the fastest one (assuming your database is up to date) and find is the slowest one. And grep is the most complex but also the most versatile one of these since you can use regexes.

share|improve this answer

grep -R "what" "where"


grep -R hello /home

share|improve this answer

The grep command is commonly used for this.

grep PATTERN filename

and grep can do some very complex searching.

willis@Cow:~$ grep --help
Usage: grep [OPTION]... PATTERN [FILE]...
Search for PATTERN in each FILE or standard input.
PATTERN is, by default, a basic regular expression (BRE).
Example: grep -i 'hello world' menu.h main.c
share|improve this answer
or you can do "rgrep word ." to recursively search every file and subdirectory for "word" – Jeremy Bicha May 2 '11 at 12:48

You can use grep to list the files containing word in the given directory:

grep -Ril word directory
share|improve this answer
Just so you know: -i performs a case-insensitive search. – David Foerster Feb 11 at 10:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.