?
Solved

how to use find command

Posted on 2011-02-27
4
Medium Priority
?
396 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 1000 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 1000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

649 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