Solved

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

Posted on 2014-01-03
7
233 Views
Last Modified: 2014-01-21
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
0
Comment
Question by:c11v11
7 Comments
 
LVL 19

Expert Comment

by:Patricksr1972
Comment Utility
Hi

I would use:

ls /directory | grep <name you are looking for>
0
 
LVL 2

Expert Comment

by:karanprabham
Comment Utility
For Speed use locate command
0
 
LVL 9

Expert Comment

by:jeff_01
Comment Utility
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 .
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 84

Expert Comment

by:ozo
Comment Utility
Can you run find on the server machine?
0
 
LVL 61

Expert Comment

by:gheist
Comment Utility
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
0
 
LVL 27

Accepted Solution

by:
serialband earned 20 total points
Comment Utility
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.
0
 
LVL 48

Expert Comment

by:Tintin
Comment Utility
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*"
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now