What is the command to search for a file name in Linux?

The find command is commonly used in Linux to search for files by their names. Here are some common ways to use the find command to search for file names:

  1. Search all files in the current directory and its subdirectories by file name.
find /path/to/directory -name "filename"
  1. Search for all files in the current directory by their file names (excluding subdirectories).
find /path/to/directory -maxdepth 1 -name "filename"
  1. Search all files in multiple specified directories by file name.
find /path/to/directory1 /path/to/directory2 -name "filename"
  1. Search all files in the current directory and its subdirectories by file name, while ignoring the case of the file name.
find /path/to/directory -iname "filename"

There are other options available to use with the find command to meet more specific search requirements. The complete documentation of the find command can be accessed by using the man find command.

bannerAds