Following on last week grep tips, let’s see how to use locate to search for files on your Linux machine.
The locate command is faster than find because it uses a database, whereas find will scan the file system every time.
locate uses a database, you first need to build it with:
$ sudo updatedbSearch recursively into a folder:
$ locate pattern folder/If no folder specified search is system-wide, ex:
$ locate "*.py"
# Filter out error msg with -q
# (permission denied, etc)
locate -q "*.py"Only count pattern occurrences:
$ locate -c patternSearch is case sensitive use -i to disable it:
$ locate -i "*.hTmL"