When you first type the find
command, the operating system will have to get the subdirectories informations from the disk. The second time you type the same command, you get the data from the cache which is faster.
If you filter the output with different pattern, find
will read each directory completely even if only some entries match the pattern. Then the cache will be full of information needed for other patterns.
However, if you use the system for a while, the cache memory could be used for other purposes… then the same find
command may have to get the data back from the disk again and can be as slow as the first time. If you want to limit the risk of having the cache memory reused, you have to add memory.