I'm on Ubuntu, and I'd like to find all files in the current directory and subdirectories whose name contains the string "John". I know that grep
can match the content of the files, but I have no idea how to use it with file names.
116
votes
4 Answers
207
votes
3
votes
The find
command will take long time because it scans real files in file system.
The quickest way is using locate
command, which will give result immediately:
locate "John"
If the command is not found, you need to install mlocate
package and run updatedb
command first to prepare the search database for the first time.
More detail here: https://medium.com/@thucnc/the-fastest-way-to-find-files-by-filename-mlocate-locate-commands-55bf40b297ab
2
votes