How to find a file based on name easily from thousands files

Most of my data is on the NFS side. There are more than hundreds of thousand files in each directory. how can find a file based on name easily?I don't what happened when I run find ./  -name "**"  but it is very slow to show the result. Anybody has any idea about this ? can you tell me what happen when I run the find command? like the inode, directory, etc
Who is Participating?

Improve company productivity with a Business Account.Sign Up

serialbandConnect With a Mentor Commented:
The find command is traversing the entire directory structure under the search directory to locate your file.

The locate command will only work on systems that have it installed or enabled.  Not all linux distros installed it by default.  The database is updated overnight and will not contain files or changes in the new day.  It's very fast at finding older existing files, but it won't find any newly created files.

if you know the subdirectory layer that your file resides in, you can also just do ls with wildcards.  There's no need to pipe to a grep.

You can find the file in the 2nd level subdirectory
ls -l subir*/*file*
ls -l  subdir/*file*
ls -l */*
ls -l */file*
ls -l sub?/file*
list the files maching the pattern file00 through file99 in subdirectories sub1 through sub9
ls -l sub[1-9]/*file[0-9][0-9]

You can even go down a 3rd level
ls -l subdir/subdir_level2/*file*
ls -l subdir[0-9]/*/*
ls -l */*/*

This will be slightly faster than the find command if you have several subdirectory layers, since it's not traversing all subdirectories and files underneath.
Patrick BogersDatacenter platform engineer LindowsCommented:

I would use:

ls /directory | grep <name you are looking for>
For Speed use locate command
Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

locate is fast but only if the index is kept up to date. It searches through a prebuilt database which is updated using the command updatedb .
Can you run find on the server machine?
If it is just thousands of files just scroll them on screen. In couple of hours you will be ready

If it is a lot more...
find /wherever -type f -name \*heeeeelp\*

you said you want to find files...and let find expand wildcard, not the shell
If you don't know what directory or sub-set of directories the file might exist in and you don't have an index of the files (via locate or any other similar command), then you are essentially stuck with the speed of traversing NFS.

Note that

find ./  -name "**"

is effectively the same as

find ./

ie:  it will match everything.

Make sure you include part of the filename in the match, eg:

find . -name "filename*"
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.