---
title: Fuzzy Search Directory in Terminal
description: In this article we'll look at a simple terminal command to do a "fuzzy search" of files and folders in a directory.
date: 2020-09-08
tags: Terminal
source: https://brianchildress.co/blog/fuzzy-search-in-terminal
---

# Fuzzy Search Directory in Terminal

Sometimes we need to find a file or folder in a directory, but struggle to remember the exact name that we're trying to find. Tab auto-completion is great but it also assumes that we know the first few letters of the thing we need to find. Here is a simple terminal command that will do a "fuzzy" search of the current directory. If you're not aware a fuzzy search is one that looks through an entire word or phrase for a matching value. The search term may appear anywhere in the title of the file or folder.

```sh
ls | grep -i <search term>
```

_Example_

```sh
ls | grep -i scrap
```

If you're a little more daring, you can search all nested folders recursively by using the `-R` flag. (Use this with caution.)

_Recursive Example_

```sh
ls -R | grep -i scrap
```

_The command breakdown:_

`ls`: List all files and folders by name in the directory
`|`: The pipe command passes data received from left side to the right side of the argument
`grep`: Use to search the results  
`-i`: Lists all files which contain the search term
