Find a file by name in UNIX/Solaris/Linux

Contributor Icon Contributed by qmchenry Date Icon September 2, 2003  
Tag Icon Tagged: UNIX

Using the find command, locate a file by name


To find a file such as filename.txt anywhere on the system:

find / -name filename.txt -print

Recent operating system versions do not require the print option because this is the default. To limit the search to a specific directory such as /usr:

find /usr -name filename.txt -print

Previous recipe | Next recipe |
 
  • snarfel
    so, i get a bunch of "Permission Denied" notices for directories that my current user account can't access. is there a way to suppress these?
  • Jesse F.
    His problem is is that he doesn't have permissions to view a lot of the files 'find' uses. Here's a few options:
    If you don't have root permission, then you can supress error messages like so: 'find -ignore_readdir_race /parent/path/here -name file_name.txt'
    Or if you can get permission, then: 'sudo find /parent/path/here -name file_name.txt'

    yay!
  • venkata sudheer
    try this # find <folder path> -name <filename> -print
  • Yeah, totally. Normal output goes to "standard output" which can be redirected with normal measures. It's actually a nice thing that those messages are sent to "standard error" so you can redirect those but keep the more interesting responses.

    find / -name something 2> /dev/null
blog comments powered by Disqus