This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| comm [2025/05/02 05:01] – ken | comm [2026/01/16 03:37] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== comm command in Linux with examples ===== | ===== comm command in Linux with examples ===== | ||
| - | |||
| The ‘comm’ command in Linux is a powerful utility that allows you to compare two sorted files line by line, identifying the lines that are unique to each file and those that are common to both. This command is particularly useful when you have lists, logs, or data sets that need to be compared efficiently. Here, we will explore the syntax, usage, options, and examples of the ‘comm’ command. | The ‘comm’ command in Linux is a powerful utility that allows you to compare two sorted files line by line, identifying the lines that are unique to each file and those that are common to both. This command is particularly useful when you have lists, logs, or data sets that need to be compared efficiently. Here, we will explore the syntax, usage, options, and examples of the ‘comm’ command. | ||
| What is the ‘comm’ Command? | What is the ‘comm’ Command? | ||
| - | + | \\ | |
| - | The ‘comm’ command is used for line-by-line comparison of two sorted files. It reads two files as input and generates a three-column output by default: | + | The ‘comm’ command is used for line-by-line comparison of two sorted files. It reads two files as input and generates a three-column output by default:\\ |
| + | \\ | ||
| Column 1: Lines unique to the first file. | Column 1: Lines unique to the first file. | ||
| Column 2: Lines unique to the second file. | Column 2: Lines unique to the second file. | ||
| Line 14: | Line 13: | ||
| \\ | \\ | ||
| < | < | ||
| - | '$comm [OPTION]... FILE1 FILE2'' | + | '$comm [OPTION]... FILE1 FILE2' |
| </ | </ | ||
| - | ‘FILE1’ and ‘FILE2′: | + | '' |
| - | ‘[OPTION]’: | + | ''' |
| - | </ | + | \\ |
| - | **Example of the ‘comm’ Command** | + | ==== Example of the ‘comm’ Command |
| Let us suppose there are two sorted files file1.txt and file2.txt and now we will use comm command to compare these two.\\ | Let us suppose there are two sorted files file1.txt and file2.txt and now we will use comm command to compare these two.\\ | ||
| **Displaying contents of file1** | **Displaying contents of file1** | ||
| Line 29: | Line 28: | ||
| Hemant | Hemant | ||
| </ | </ | ||
| + | \\ | ||
| **Displaying contents of file2** | **Displaying contents of file2** | ||