> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Find Files by Name in Linux
- URL: https://linuxhandbook.com/find-files-by-name/
- Published: 2022-09-24T14:34:03.000Z
- Updated: 2023-10-19T14:20:18.000Z
- Description: Finding files by their name is one of the most common scenarios of finding files in Linux. Here are a few examples to help.
- Author: Abhishek Prakash
- Tags: Quick Tip

Most often, you are looking for a file on Linux and you do not exactly know its true location on the system disk.

There are multiple ways to [find files in the Linux command line](https://learnubuntu.com/find-files/?ref=linuxhandbook.com). Most common and most reliable way is to use the find command.

The [find command is extremely versatile and has way too many usages](https://linuxhandbook.com/find-command-examples/) but here I'll focus on finding files by their name.

I'll explain how to use the ‘find’ command for:

- Searching files using their name
- Searching files with their exact name
- Searching files for a particular pattern
- Searching multiple files
- Excluding certain files from the search results.

Besides these, I'll also show [how to use the grep command](https://linuxhandbook.com/grep-command-examples/) with the output from the find command. Let’s first start with an overview of the `find` command.

The utility ‘find’ looks for files that match a certain set of parameters like the file’s name, its modification date, its extension, etc. It has the following format:

```
find path pattern
```

If the [file path](https://linuxhandbook.com/get-file-path/) is not specified, it searches in the current directory and its sub-directories.

## Searching for Files Using their Name

Looking for a file with its name is a commonly used operation with the find command. The `-iname` option looks for a file regardless of its case. 

For example, suppose you have two files abc.txt and ABC.txt. Both of them have the same name but different cases. Using the find command, you get both files in the results:

```
find -iname abc.txt
```

![Find files with their name](https://linuxhandbook.com/content/images/2022/09/find-files-with-name-case-ignore.png)

Find files with their name while ignoring the case

## Searching for Files Using their Exact Name

The `-name` option is case-sensitive in contrast to the `-iname` option, so you are going to get files with the exact name. 

For example, let us look for a file with the name `abc.txt` :

```
find -name abc.txt
```

![Find files with exact name](https://linuxhandbook.com/content/images/2022/09/find-files-with-exact-name.png)

The name of the file can be composed of wildcards as you will see later in this guide.

## Searching for Files With a Particular Pattern

You can also filter files that follow a given pattern. For that, you can use wildcards. 

Say, for instance, you are looking for all the configuration files on your system that end with the '.conf' extension:

```
find /etc -type f -name "*.conf" | grep client.conf
```

![Find files with their extension](https://linuxhandbook.com/content/images/2022/09/find-files-by-extension.png)

Find files with a certain extension

In the same way, you can also **search for files with the same name but with any extension** of three characters as:

```
find ~ -name "abc.???" 
```

![Find files with any extension](https://linuxhandbook.com/content/images/2022/09/find-files-with-extension.png)

Find files with the same name but any extension

If you have several **file names that contain a common string**, say ‘VM’, the find command in this scenario will be as:

```
find -name '*VM*' 
```

![Find files with a matching pattern](https://linuxhandbook.com/content/images/2022/09/find-files-with-pattern-in-name.png)

Find files with a matching pattern

So far, we have used a single directory (the *home* directory) with the ‘find’ command. 

You can also **search in multiple directories** by specifying them on the CLI:

```
find ~/Desktop/example1/ ~/Desktop/example2/ -name 'abc*.*'
```

![Find files in multiple directories](https://linuxhandbook.com/content/images/2022/09/find-files-in-multiple-directories.png)

Find files in multiple directories

## Searching for Multiple Files and Multiple Patterns

Suppose you want to find multiple files in a directory having `.*msi*` and `.*txt*` as file types. 

Here you need to use both the `name` and `type` options on the CLI as:

```
find -type f \( -name "*.txt" -o -name "*.msi" \)
```

![Search for multiple files](https://linuxhandbook.com/content/images/2022/09/search-for-multiple-files.png)

Search for multiple files and multiple patterns

In a similar approach, you can extend the above command for more files by using extra `-o` options.

## Excluding Certain Files from the Search Results

The find command can also exclude certain types of files from the search result:

```
find -name '*abc*' -type f \( ! -name '*.msi' \)
```

![Exclude certain files from find search results](https://linuxhandbook.com/content/images/2022/09/exclude-certain-files-from-find-search-result.png)

Exclude certain files from find search results

Here, the ‘find’ command will look for all the files having *‘abc’* string in their name. However, it will filter out the `.msi` type of files.

## Other Common Examples of the 'find' Command

You have more options that can be used with the ‘find’ command. Let me share a few such examples: 

System reporting low disk space? [Find bigger files](https://linuxhandbook.com/find-biggest-files-linux/) like this:

```
find -size +2000M
```

Using the above command, you can find files occupying more than 2000 Megabytes of space.

In case you need to save your findings for later investigation*,* redirect it to a file:

```
find -name '*abc*' -type f \( ! -name '*.msi' \) > mysearch.txt
```

![Save the result of the find command](https://linuxhandbook.com/content/images/2022/09/save-find-command-result.png)

Save the result of the find command

The `type` option with the find command opens many opportunities. 

You can combine it with different file descriptors for different types of files. For example, ‘f’ for a regular file, ‘d’ for a directory, ‘l’ for a [symbolic link](https://linuxhandbook.com/symbolic-link-linux/), etc.

```
find /var/log -type f -name "*.log" 
```

## Conclusion

In this guide, I explained how to search for files by their names using the find command. You saw multiple ways to narrow down the search path and most importantly, how to incorporate the ‘wildcards’ for pattern searching.

There are many more uses of the find command. Like you can use it to [find recently modified files](https://linuxhandbook.com/find-modified-files/). Here are a few more common examples if you are interested. 

[15 Super Useful Examples of Find Command in LinuxLearn the super powerful and super useful find command with these practical examples.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookAbhishek Prakash![](https://linuxhandbook.com/content/images/2021/10/Find-Command-examples.webp)](https://linuxhandbook.com/find-command-examples/)

You can [always search man pages](https://linuxhandbook.com/man-pages/) to get extensive insights into the various options with the ‘find’ command.