> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/unix/grep-using-input-file-as-pattern-to-search-other-file.md).

# grep using input file as pattern to search other file

Sometimes we need to use another file which contains a multiple line that we want to use as input pattern

example:

You have `a.txt`

```
a
b
c
d
e
```

And you want to search `a`, `c`, `e`.

This case you can create `input.txt`

```
a
c
e
```

and use this command

```
grep -f -F input.txt a.txt
```

If the input txt is a list of *regex* you can remove the `-F` option.

```
 -F, --fixed-strings
              Interpret PATTERNS as fixed strings, not regular expressions.
```
