Results 1 to 6 of 6

Thread: [SOLVED] In terminal, is there a difference between find and locate?

  1. #1
    Join Date
    Feb 2007
    Location
    Topeka, Kansas
    Beans
    2,317
    Distro
    Ubuntu 13.10 Saucy Salamander

    [SOLVED] In terminal, is there a difference between find and locate?

    The find command... The locate command. What's different?

  2. #2
    Join Date
    Aug 2007
    Location
    Manchester, UK
    Beans
    10,285
    Distro
    Ubuntu

    Re: In terminal, is there a difference between find and locate?

    I'm not sure exactly - but this happens with find
    Code:
    :~$ find topsecret
    find: topsecret: No such file or directory
    Whereas if I use locate, I get this
    Code:
    :~$ locate topsecret
    /home/joe/topsecretstuff
    /usr/share/cups/banners/topsecret
    So that's why I use locate...actually I sometimes use
    Code:
     locate <file> | less
    That's if I think it'll return a lot of results

  3. #3
    Join Date
    Jun 2008
    Beans
    263

    Re: In terminal, is there a difference between find and locate?

    locate uses a database and index method so is faster but the database has to be updated regularly and so can be unreliable if it isn't. find does an actual directory hierarchy search each time and is slower but more relaible.
    Last edited by the_doc; June 14th, 2008 at 04:26 PM.

  4. #4
    Join Date
    Nov 2006
    Location
    Mumbai, India
    Beans
    652

    Re: In terminal, is there a difference between find and locate?

    I think find searches in the current directory only. Locate brings more results
    [Arch + KDE]

  5. #5
    Join Date
    Aug 2007
    Location
    Manchester, UK
    Beans
    10,285
    Distro
    Ubuntu

    Re: In terminal, is there a difference between find and locate?

    You can update that database anytime you want, by running
    Code:
    updatedb
    From a terminal

  6. #6
    Join Date
    Jun 2008
    Beans
    263

    Re: In terminal, is there a difference between find and locate?

    Locate will return results from all over the filesystem whereas find will only search the current dir unless specified otherwise.

    It's also easier to update the database for locate with a cron job.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •