# find lines that matches on 2 different sorted file

Supposed we have 2 sorted files:

file1&#x20;

```
1
2
3
4
5
```

file2

```
3
4
5
6
7
```

`comm` is a utility for finding lines that appear (or not) between 2 files. The normal output are 3 column.&#x20;

1. Lines that is unique on file 1
2. Lines that is unique on file 2
3. Lines that are appear on both

### Examples

```bash
$ comm  file1 file2
1
2
		3
		4
		5
	6
	7
```

#### Find lines that on both file only

```bash
$ comm -12 file1 file2
3
4
5
```

`-12` supresses (do not include) colunm 1 & 2

#### Fine line that is unique on first file

```bash
$ comm -23 file1 file2
1
2
```

#### For file that is not uniq or sorted

If file is not sorted, you can use the `<(..)` operator

```bash
$ comm <(sort -u file1) <(sort -u file2)
1
2
		3
		4
		5
	6
	7
```


---

# 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/find-lines-that-matches-on-2-different-sorted-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.
