The Memory Bank

...for memory blanks

Site Tools


comm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
comm [2025/05/02 04:55] – created kencomm [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.
     Column 3: Lines common to both files.     Column 3: Lines common to both files.
- +\\ 
-Syntax: +**Syntax:** 
- +\\ 
-$comm [OPTION]... FILE1 FILE2 +<code> 
- +'$comm [OPTION]... FILE1 FILE2' 
-    ‘FILE1’ and ‘FILE2′: The sorted files to compare. +</code> 
-    ‘[OPTION]’: Flags to modify the command’s output. +''‘[OPTION]’: Flags to modify the command’s output.''\\ 
- +'''FILE1’ and ‘FILE2′: The sorted files to compare.''\\ 
-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** 
 +<code>
 $cat file1.txt $cat file1.txt
 Apaar  Apaar 
Line 28: Line 27:
 Deepak Deepak
 Hemant Hemant
- +</code>\\ 
-Displaying contents of file2+\\ 
 +**Displaying contents of file2**
  
 $cat file2.txt $cat file2.txt
comm.1746161717.txt.gz · Last modified: (external edit)