Description:
Syntax:
comm - compare two sorted files line by line and write to standard output, the lines that are common, plus the lines that are unique.
Syntax:
comm [options].. File1 File2
Options:
-1 suppress lines unique to file1.
-2 suppress lines unique to file2.
-3 suppress lines that appear in both files.
For Example:
Consider I have 2 sorted files.
Nirmals-MBP:nirmalg$ cat a.txt
a
b
c
d
Nirmals-MBP:nirmalg$ cat b.txt
c
d
Nirmals-MBP:nirmalg$
To get the common lines from both the files.
Nirmals-MBP:nirmalg$ comm -12 a.txt b.txt
c
d
Nirmals-MBP:nirmalg$
To get uncommon lines between both the files.
Nirmals-MBP:nirmalg$ comm -23 a.txt b.txt
a
b
Nirmals-MBP:nirmalg$
For Example:
Consider I have 2 sorted files.
Nirmals-MBP:nirmalg$ cat a.txt
a
b
c
d
Nirmals-MBP:nirmalg$ cat b.txt
c
d
Nirmals-MBP:nirmalg$
To get the common lines from both the files.
Nirmals-MBP:nirmalg$ comm -12 a.txt b.txt
c
d
Nirmals-MBP:nirmalg$
To get uncommon lines between both the files.
Nirmals-MBP:nirmalg$ comm -23 a.txt b.txt
a
b
Nirmals-MBP:nirmalg$
No comments:
Post a Comment