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
For Speed use locate command
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 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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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*"
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*"
I would use:
ls /directory | grep <name you are looking for>