Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-03
7
Medium Priority
?
246 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 23

Expert Comment

by:Patrick Bogers
ID: 39753277
Hi

I would use:

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

Expert Comment

by:karanprabham
ID: 39753279
For Speed use locate command
0
 
LVL 9

Expert Comment

by:jeff_01
ID: 39753669
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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 84

Expert Comment

by:ozo
ID: 39753684
Can you run find on the server machine?
0
 
LVL 62

Expert Comment

by:gheist
ID: 39755306
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 30

Accepted Solution

by:
serialband earned 60 total points
ID: 39756309
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
ID: 39757988
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

704 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