# 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.
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.yulrizka.com/unix/grep-using-input-file-as-pattern-to-search-other-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
