Avatar of c11v11
c11v11
 asked on

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
Linux

Avatar of undefined
Last Comment
Tintin

8/22/2022 - Mon
Patrick Bogers

Hi

I would use:

ls /directory | grep <name you are looking for>
karanprabham

For Speed use locate command
jeff_01

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 .
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ozo

Can you run find on the server machine?
gheist

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
ASKER CERTIFIED SOLUTION
serialband

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Tintin

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*"
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.