Do you know a good way to find a file or content by name recursively similar to the ms-windows function search with Linux? I can do find . | grep test.html suspecting it's not the best. Thanks for any answer.

For instance, running find . | grep terms.htmlgives my expected result while locate terms.html doesn't even though locate gets updated db - it might have to do with that it's an USB stick the file is on?


The command is find, like this

 find . -iname '*hellofiles*'

you say find ·location· -iname means not case sensitive and in the '' is a regular expression if you wish.

find /home/user -iname '*zip' will find you all the zip files in /home/user

If you want a faster lookup you can use locate, there is a utility which scanns the disc regulary, like every week or day dependin on how it is setup

locate myfile

and it will look in the database if updatedb has seen myfile anywhere.

  • This has helped me many times rather than locate – Niklas R. Nov 19 '11 at 19:33

find has a number of options that allow it to find files by name, regular expressions or even more complex criteria such as size or ownership. E.g.

find . -iname '*.txt'

See also the example section in the linked manual page.

That said, find has the distinct disadvantage of searching the filesystem each time that you call it. The locate utility, in its many variations, on the other hand, uses a regularly-updated database of the files in your system.

  • Thanks! The command find . -iname privacy.html gives the expected result while locate doesn't (it's a file privacy.html I serched after on a USB memory) – Niklas R. Sep 1 '11 at 15:45

In case of packages: dpkg -L packagename

or if you know that it is in a particular folder, add the use of grep, like:

dpkg -L packagename | grep foldername

For example you just installed Chromium and you need to know where is the bin

dpkg -L chromium-browser | grep bin


find ./ -name "filename" or you can do something like find ./ -name "*.jar" to find all the files with the .jar extension. You can also do find ./ -name "*.jar" | xargs grep -n 'main' to find all the .jar files that contain a main in them.


find . -name test.html or you can use wildcards too: find . -name \*test.html


You could use the command find, if you wish to do this via a terminal.

Pipelining find and grep will work, otherwise find provides itself some options (like -name and -iname) to do this:

find DIRECTORY -name test.html

There are two utilities find and locate. Since others have suggested find, I will talk about locate.

You install a package named mlocate or slocate on older systems. After installing run the command updatedb. locate uses a database to store the path to all of your files, so searching is much faster but it has the disadvantage of going out of date frequently, and populating the database can take a couple of minutes.

Once you have the database populated just run: locate file. If you just use the name of the file it will search for that file starting from /. So you could get /etc/file and /usr/share/file. If you want to just limit it to your home directory use this:

 locate file | grep /home/user

Wildcards don't work with locate for whatever reason.

  • 1
    locate does do shell globs a.k.a. wildcards. You may need to quote your pattern then. You can also use the -r flag to use regular expressions. – Rich Homolka Feb 1 '11 at 21:07

I don't know the Windows search function, but when you looking for an alternative to | grep * then you can try:

find /* -name "keyword"

slocate should also fit into your criteria.

Regards, /dley

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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