Is there a way to increase `find` speed

I am asking yourself exists a means to increase find rate in terminal, it does not make good sense that making use of net google to look will certainly have a far better rate than doing a neighborhood look for strings or simply submit names.

I am asking yourself exists a means to have a neighborhood indexing base, as soon as constructed, in the future, the find command can be extremely quickly.

Or any kind of various other pointers?

Many thanks!

2022-06-07 14:39:30
Source Share
Answers: 4

Try making use of locate, it needs to do what you desire.

2022-06-07 15:12:00

As others have actually mentioned, situate might be a far better device for less complex searcher.

Nonetheless, for extra intricate searches you are possibly stuck to find.

One means to quicken find is to limit which directory your documents remain in as opposed to looking every one of the origin directory.

2022-06-07 15:11:34

Use locate

The factor is that locate makes use of a data source of all the existing directory sites and also documents that is currently been constructed similar to you imagined!ยข

At some set (and also unpredictable) period, a work runs does checks the documents system and afterwards constructs a data source with it. It is after that this data source (locatedb), with its ideal indexes that the locate command violates as opposed to scanning via your disk drive then.

So the advantage is that it is really quickly in contrast to a disk drive check. The disadvantage is that the situate data source (locatedb) is not 'live' so can just be made use of for documents that existed 'since' the last check.

To upgrade locatedb currently run updatedb (or sudo updatedb if essential)

btw I simply ran sudo updatedb in your area and also it took 3 1/2 secs! I have 31,000 documents.

2022-06-07 15:11:11

It depends a lot on what your search standard is.

If you look for filenames or filename patterns, situate is much quicker, yet not ideal for fresh created documents, given that the index made use of is generally upgraded just as soon as daily. Yet if you can utilize it, it is extremely quickly.

Yet with find you can look for documents dimension, documents age and also various other points, which aren't searchable by situate.

If you recognize where to look, you can make use of the course to delimit the search extent:

find /some/path -size -10M -size +2M -mtime -365 ...

would just look documents from 2 to 10 M, maximum 1 years of age in/ some/path.

Programs, readily available in the course can be looked by which ; aid, lib and also arrangement documents with whereis . Instances:

which java

whereis firefox 
firefox: /usr/bin/firefox /etc/firefox /usr/lib/firefox /usr/share/firefox /usr/share/man/man1/firefox.1.gz

If you execute programs on every documents you find with - director, - execdir, - ok or - okdir, which is readily available in GNU - find as an example, you can pass numerous documents simultaneously to the program, if the program sustains being called with numerous debates, by finishing your command with "+" as opposed to " ;". Instance:

find -name "*.pdf" -exec ls -l {} "+" 

This can quicken the entire procedure dramatically, yet depends a lot on specific conditions.

2022-06-07 15:06:39