What situation is `find` and `locate` best used in? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












I know that locate has to have a database generated and is much faster, and that find does not need a database generated and is not as fast. So in what situations is find and locate more efficient/affective/give a better end result?







share|improve this question














closed as primarily opinion-based by Thomas Dickey, steve, Chris Down, Jeff Schaller, Stephen Rauch Dec 15 '17 at 23:58


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.














  • A duplicate of unix.stackexchange.com/q/60205/117549
    – Jeff Schaller
    Dec 16 '17 at 3:23










  • @JeffSchaller I don’t think my question is exactly a duplicate, though there are similarities... While my question is asking the pros and cons, I am asking in what situations would either of the two command be more efficient and affective and give better results.
    – StrangeRanger
    Dec 16 '17 at 4:45















up vote
-1
down vote

favorite












I know that locate has to have a database generated and is much faster, and that find does not need a database generated and is not as fast. So in what situations is find and locate more efficient/affective/give a better end result?







share|improve this question














closed as primarily opinion-based by Thomas Dickey, steve, Chris Down, Jeff Schaller, Stephen Rauch Dec 15 '17 at 23:58


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.














  • A duplicate of unix.stackexchange.com/q/60205/117549
    – Jeff Schaller
    Dec 16 '17 at 3:23










  • @JeffSchaller I don’t think my question is exactly a duplicate, though there are similarities... While my question is asking the pros and cons, I am asking in what situations would either of the two command be more efficient and affective and give better results.
    – StrangeRanger
    Dec 16 '17 at 4:45













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I know that locate has to have a database generated and is much faster, and that find does not need a database generated and is not as fast. So in what situations is find and locate more efficient/affective/give a better end result?







share|improve this question














I know that locate has to have a database generated and is much faster, and that find does not need a database generated and is not as fast. So in what situations is find and locate more efficient/affective/give a better end result?









share|improve this question













share|improve this question




share|improve this question








edited Dec 15 '17 at 23:09

























asked Dec 15 '17 at 22:57









StrangeRanger

9119




9119




closed as primarily opinion-based by Thomas Dickey, steve, Chris Down, Jeff Schaller, Stephen Rauch Dec 15 '17 at 23:58


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as primarily opinion-based by Thomas Dickey, steve, Chris Down, Jeff Schaller, Stephen Rauch Dec 15 '17 at 23:58


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.













  • A duplicate of unix.stackexchange.com/q/60205/117549
    – Jeff Schaller
    Dec 16 '17 at 3:23










  • @JeffSchaller I don’t think my question is exactly a duplicate, though there are similarities... While my question is asking the pros and cons, I am asking in what situations would either of the two command be more efficient and affective and give better results.
    – StrangeRanger
    Dec 16 '17 at 4:45

















  • A duplicate of unix.stackexchange.com/q/60205/117549
    – Jeff Schaller
    Dec 16 '17 at 3:23










  • @JeffSchaller I don’t think my question is exactly a duplicate, though there are similarities... While my question is asking the pros and cons, I am asking in what situations would either of the two command be more efficient and affective and give better results.
    – StrangeRanger
    Dec 16 '17 at 4:45
















A duplicate of unix.stackexchange.com/q/60205/117549
– Jeff Schaller
Dec 16 '17 at 3:23




A duplicate of unix.stackexchange.com/q/60205/117549
– Jeff Schaller
Dec 16 '17 at 3:23












@JeffSchaller I don’t think my question is exactly a duplicate, though there are similarities... While my question is asking the pros and cons, I am asking in what situations would either of the two command be more efficient and affective and give better results.
– StrangeRanger
Dec 16 '17 at 4:45





@JeffSchaller I don’t think my question is exactly a duplicate, though there are similarities... While my question is asking the pros and cons, I am asking in what situations would either of the two command be more efficient and affective and give better results.
– StrangeRanger
Dec 16 '17 at 4:45











2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










As you said, locate has a database and is therefore much faster, while find has to traverse the filesystem.
But locate's database only contains filenames (with their paths), while find can select files based on other meta data like mtime or size. So it is my resume versatile.
Also the database has to be updated in a batch effort, usually nightly, so files which have been created modified recently do not appear correctly.
Also you can expect every modern Unix system to have find available, while not all systems have locate's database enabled.



So, locate is faster, use it to find the location of a file, find is more versatile. There is no universal better.






share|improve this answer




















  • I'm not an expert with either command by any means so take this with a grain of salt. However I believe another caveat of the locate database is that it will only include paths that the user who created it has read access. To me this means that even if run with sudo it may not find files that would be otherwise located with find.
    – Jesse_b
    Dec 15 '17 at 23:15

















up vote
0
down vote













Typically the locate database is updated once per day. So if you need to search for anything that is newer than one day, you may need find for that.



On the other hand, the larger the filesystem you need to search, the faster locate will be over find. Especially so if the filesystem is on a network share.






share|improve this answer



























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    As you said, locate has a database and is therefore much faster, while find has to traverse the filesystem.
    But locate's database only contains filenames (with their paths), while find can select files based on other meta data like mtime or size. So it is my resume versatile.
    Also the database has to be updated in a batch effort, usually nightly, so files which have been created modified recently do not appear correctly.
    Also you can expect every modern Unix system to have find available, while not all systems have locate's database enabled.



    So, locate is faster, use it to find the location of a file, find is more versatile. There is no universal better.






    share|improve this answer




















    • I'm not an expert with either command by any means so take this with a grain of salt. However I believe another caveat of the locate database is that it will only include paths that the user who created it has read access. To me this means that even if run with sudo it may not find files that would be otherwise located with find.
      – Jesse_b
      Dec 15 '17 at 23:15














    up vote
    1
    down vote



    accepted










    As you said, locate has a database and is therefore much faster, while find has to traverse the filesystem.
    But locate's database only contains filenames (with their paths), while find can select files based on other meta data like mtime or size. So it is my resume versatile.
    Also the database has to be updated in a batch effort, usually nightly, so files which have been created modified recently do not appear correctly.
    Also you can expect every modern Unix system to have find available, while not all systems have locate's database enabled.



    So, locate is faster, use it to find the location of a file, find is more versatile. There is no universal better.






    share|improve this answer




















    • I'm not an expert with either command by any means so take this with a grain of salt. However I believe another caveat of the locate database is that it will only include paths that the user who created it has read access. To me this means that even if run with sudo it may not find files that would be otherwise located with find.
      – Jesse_b
      Dec 15 '17 at 23:15












    up vote
    1
    down vote



    accepted







    up vote
    1
    down vote



    accepted






    As you said, locate has a database and is therefore much faster, while find has to traverse the filesystem.
    But locate's database only contains filenames (with their paths), while find can select files based on other meta data like mtime or size. So it is my resume versatile.
    Also the database has to be updated in a batch effort, usually nightly, so files which have been created modified recently do not appear correctly.
    Also you can expect every modern Unix system to have find available, while not all systems have locate's database enabled.



    So, locate is faster, use it to find the location of a file, find is more versatile. There is no universal better.






    share|improve this answer












    As you said, locate has a database and is therefore much faster, while find has to traverse the filesystem.
    But locate's database only contains filenames (with their paths), while find can select files based on other meta data like mtime or size. So it is my resume versatile.
    Also the database has to be updated in a batch effort, usually nightly, so files which have been created modified recently do not appear correctly.
    Also you can expect every modern Unix system to have find available, while not all systems have locate's database enabled.



    So, locate is faster, use it to find the location of a file, find is more versatile. There is no universal better.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 15 '17 at 23:05









    Thomas

    44427




    44427











    • I'm not an expert with either command by any means so take this with a grain of salt. However I believe another caveat of the locate database is that it will only include paths that the user who created it has read access. To me this means that even if run with sudo it may not find files that would be otherwise located with find.
      – Jesse_b
      Dec 15 '17 at 23:15
















    • I'm not an expert with either command by any means so take this with a grain of salt. However I believe another caveat of the locate database is that it will only include paths that the user who created it has read access. To me this means that even if run with sudo it may not find files that would be otherwise located with find.
      – Jesse_b
      Dec 15 '17 at 23:15















    I'm not an expert with either command by any means so take this with a grain of salt. However I believe another caveat of the locate database is that it will only include paths that the user who created it has read access. To me this means that even if run with sudo it may not find files that would be otherwise located with find.
    – Jesse_b
    Dec 15 '17 at 23:15




    I'm not an expert with either command by any means so take this with a grain of salt. However I believe another caveat of the locate database is that it will only include paths that the user who created it has read access. To me this means that even if run with sudo it may not find files that would be otherwise located with find.
    – Jesse_b
    Dec 15 '17 at 23:15












    up vote
    0
    down vote













    Typically the locate database is updated once per day. So if you need to search for anything that is newer than one day, you may need find for that.



    On the other hand, the larger the filesystem you need to search, the faster locate will be over find. Especially so if the filesystem is on a network share.






    share|improve this answer
























      up vote
      0
      down vote













      Typically the locate database is updated once per day. So if you need to search for anything that is newer than one day, you may need find for that.



      On the other hand, the larger the filesystem you need to search, the faster locate will be over find. Especially so if the filesystem is on a network share.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Typically the locate database is updated once per day. So if you need to search for anything that is newer than one day, you may need find for that.



        On the other hand, the larger the filesystem you need to search, the faster locate will be over find. Especially so if the filesystem is on a network share.






        share|improve this answer












        Typically the locate database is updated once per day. So if you need to search for anything that is newer than one day, you may need find for that.



        On the other hand, the larger the filesystem you need to search, the faster locate will be over find. Especially so if the filesystem is on a network share.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 15 '17 at 23:17









        telcoM

        10.8k11232




        10.8k11232












            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)