---
title: Find a File in a Directory Using Unix Command
description: In this short article we'll take a look at a command that allows you to search a directory or subdirectory for a file based on some pattern.
date: 2020-07-24
tags: Unix, terminal
source: https://brianchildress.co/blog/find-a-file-in-directory-in-unix
---

# Find a File in a Directory Using Unix Command

If you've ever needed to find a file in a directory or subdirectory without clicking around this handy terminal command might help you find the file(s) more quickly.

The _[find](https://kb.iu.edu/d/admm)_ command will search directories based on a name or pattern supplied.

_Example_

```sh
find /path/to/dir -name "my-missing-file" -print
```

Let's break this down:

| Command           | Purpose                                                                             |
| :---------------- | :---------------------------------------------------------------------------------- |
| **/path/to/dir**  | The path (relative or absolute) path to begin searching                             |
| -name             | The _name_ flag will search all files in all directories for a match to the pattern |
| "my-missing-file" | The pattern of the filename to match, could be something like: *.jpg                |
| -print            | Will print the path for the matching files                                          |
