Search based on name or regular expression match

The -name argument specifies a selection pattern for the name. The -name argument accepts both glob-style wildcards and regular expressions. In the following example, '*.txt' matches all the file or folder names ending with .txt and prints them.

Note the single quotes around *.txt. The shell will expand glob wildcards with no quotes or using double-quotes ("). The single quotes prevent the shell from expanding the *.txt and passes that string to the find command.
$ find /home/slynux -name '*.txt' -print

The find command has an option -iname (ignore case), which is similar to -name, but it matches filenames regardless of case.

Consider the following example:

$ ls
example.txt EXAMPLE.txt file.txt ...

Get Linux Shell Scripting Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.