Finding files and directories in Linux.
Case-insensitive file searching with the locate command
It’s easy to perform a case-insensitive file search with the Linux locate command: just add the -i flag. To search my entire filesystem for files and directories that contain the string typeahead, just use this command:
locate -i typeahead
Case-insensitive file searching with the find command
If for some reason you can’t find your files with the Linux locate command, or your system doesn’t have the locate command installed, you can also try searching with the traditional Unix find command. Here’s how I did a case-insensitive search trying to find the same typeahead files with the find command:
find . -type f -iname "*typeahead*"
(FWIW, I add the -type f option to tell find to just look for files, and not directories.)
Note that on some systems you may also have to use the -print option at the end of that command, like this:
find . -type f -iname "*typeahead*" -print
The key to that case-insensitive search is the use of the -iname option, which is only one character different from the -name option. The -iname option is what makes the search case-insensitive.
More find command options
The Linux find command has several more case-insensitive operators, including these, which I’m taking directly from the find command man page:
Like -lname, but the match is case insensitive.
If the -L option or the -follow option is in effect,
this test returns false unless the symbolic link is broken.
Like -regex, but the match is case insensitive.
Like -wholename, but the match is case insensitive.