https://en.wikipedia.org/wiki/Comm
# show only items in both a and b
comm -1 -2 a_list b_list
# show only items unique to a
comm -2 -3 a_list b_list
# show only items unique to b
comm -1 -3 a_list b_listhttps://en.wikipedia.org/wiki/Comm
# show only items in both a and b
comm -1 -2 a_list b_list
# show only items unique to a
comm -2 -3 a_list b_list
# show only items unique to b
comm -1 -3 a_list b_listI think the same thing happens to a lesser degree with vim features.
Other boring, but instructive reads (heavily GNU biased): diffutils [1], findutils [2], the Bash manual [3].
[0]: https://www.gnu.org/software/coreutils/manual
[1]: https://www.gnu.org/software/diffutils/manual
[2]: https://www.gnu.org/software/findutils/manual/find.html
# show only items in both a and b
comm -1 -2 <(sort -u a_list) <(sort -u b_list)
# show only items unique to a
comm -2 -3 <(sort -u a_list) <(sort -u b_list)
# show only items unique to b
comm -1 -3 <(sort -u a_list) <(sort -u b_list) comm <flags> <(command 1) <(command 2)
To use the output of a command as input.
This also works with diff and other commands.The '<( ... )' is just giving the path to that command's stdout as a file descriptor.
$ ls <(echo hi)
/proc/self/fd/11
$ vi <(echo hi)
# opens vi with 'hi' as the contentshttp://www.tldp.org/LDP/abs/html/process-sub.html
With fish:
https://fishshell.com/docs/current/commands.html#psub
But there it only works one way:
[0] https://gist.github.com/hadrianw/060944011acfcadd889d937b960...
What the blog post does (doing cat multiple times, and then counting the occurrences) is going to be much slower, although mathematically correct.
comm "not only in 1" and "not in both"
so:
comm -1 -3 file1 file2