4 ms·
locate may be the most-overlooked timesaver on the GNU distro. For searches of more than ~50000 directories, it's an order of magnitude faster than find: $
by everybodyknows 9y ago
locate may be the most-overlooked timesaver on the GNU distro. For searches of more than ~50000 directories, it's an order of magnitude faster than find:
$ time locate -0 /{opt,usr}/\*.gitignore |
xargs -0 stat --format=%s | wc
387 387 1225
real 0m0.087s
$ time find /{opt,usr} -name '.gitignore' -print0 2>/dev/null |
xargs -0 stat --format=%s | wc
387 387 1225
real 0m0.748s
The speedup comes from reading a single database file rather than every directory within the tree to be searched. If the files you want were last touched today, a manually triggered rebuild of the database may be needed:
$ sudo updatedb
The argument syntax for path specification of locate I find more convenient as well.