Solved

how to use find command

Posted on 2011-02-27
4
371 Views
Last Modified: 2012-05-11
If I'm logged in as root and change to the root directory the following command works as expected:
find -name myfile

If however I do:
find / -name myfile
it lists every directory on the drive.
This second option would be handy so I wouldn't have to switch to the root every time I want to search for a file.

Why does it do that and what should I type/
0
Comment
Question by:davidpm
[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
4 Comments
 
LVL 16

Expert Comment

by:santoshmotwani
ID: 34993713
You syntax is right but it may be possible there are multiple files with the same name

find / -name myfile

Its searching the whole system for any files named  myname and displayign their pathnames.  

You can be more specific about type of files by adding extension to file name or use grep to get only specific files you want
0
 
LVL 35

Accepted Solution

by:
torimar earned 250 total points
ID: 34993756
If you use the find command on the / root filesystem and you are not root, then the command usually will list all those folders that you cannot access for permissions issues - which will be all the folders on the system except the home folder of the user you are logged in as.

You could suppress the error messages by adding a redirection to your command:

find / -name myfile 2>/dev/null
0
 
LVL 10

Assisted Solution

by:APNFSSC
APNFSSC earned 250 total points
ID: 34993969
Hi,

Try this, the -type f tell's find to ignore directories and only list files.

find / -type f -name myfile
0
 

Author Closing Comment

by:davidpm
ID: 34994093
Thanks
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Check for Linux process in script 7 85
AWK: Pythagoras bp script 18 47
Can't "Unset" Proxy in Apache headers for PCI compliance... 4 89
SMTP log file for IMSVA 5 68
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Utilizing an array to gracefully append to a list of EmailAddresses
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

738 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