Using GNU comm to compare sorted files line by line.  
This is similar to PHP's array_diff and Java's removeAll(). Helpful in finding diffs between lists of ids.

angelcool@fedora-laptop$cat FILE1.txt 
1
2
3
4
5
5
angelcool@fedora-laptop$cat FILE2.txt
1
2
3
4
5
6
7
8
9
angelcool@fedora-laptop$comm -13 <(sort FILE1.txt|uniq) <(sort FILE2.txt|uniq)
6
7
8
9
angelcool@fedora-laptop$ man comm
...
Compare sorted files FILE1 and FILE2 line by line.

When FILE1 or FILE2 (not both) is -, read standard input.

With no options, produce three-column output. Column one contains lines unique to FILE1, column two con‐
tains lines unique to FILE2, and column three contains lines common to both files.

-1 suppress column 1 (lines unique to FILE1)

-2 suppress column 2 (lines unique to FILE2)

-3 suppress column 3 (lines that appear in both files)

--check-order
check that the input is correctly sorted, even if all input lines are pairable

--nocheck-order
do not check that the input is correctly sorted

--output-delimiter=STR
separate columns with STR

--total
output a summary

-z, --zero-terminated
line delimiter is NUL, not newline

--help display this help and exit

--version
output version information and exit

Note, comparisons honor the rules specified by 'LC_COLLATE'.
...


[ view entry ] ( 78 views )   |  print article

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next> Last>>


2025 By Angel Cool