File Name Search in Ubuntu

Posted on 2011-10-24
Last Modified: 2012-05-12
From the command line how do i search for a specific file name in ubuntu?
Question by:deklinm
    LVL 68

    Accepted Solution

    find /start/dir -type f -name file-to-search-for -print
    LVL 31

    Assisted Solution

    man find

    to see all options

    All you need is a suspected directory and a filename.  As WPM said, you can certainly use -name option for the filename pattern or you can use -iname if you are not sure about the case like ABC or abc.

    find /directory  -name '*txt'

    Author Comment

    so i am tying to local a file called photo.jpg.

    When i run the below syntax i receive an unknown predicate response.

    find /start/dir -type f -name photo.jpg -print

    LVL 68

    Assisted Solution

    Replace /start/dir with the name of the top level directory of the directory hierarchy which is suspected to contain the file in question.
    LVL 31

    Expert Comment

    Try this

    find . -type f -name photo.jpg

    This would find for all the files under the current directory and all the sub directories.

    May be you didn't change /start/dir.  It was just an example by WMP.
    LVL 6

    Expert Comment

    simply try
    locate photo.jpg

    If you added the file recently, try updatedb as an admin then enter the above command

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    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.

    754 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

    24 Experts available now in Live!

    Get 1:1 Help Now