from Hacker News

Checking It Twice

by arm on 9/17/21, 1:48 AM with 4 comments

  • by herne on 9/20/21, 9:43 PM

    I ended up with this in my .bashrc so I didn't have to keep remembering how to use comm each time:

      justA()  { comm -23 <(sort -u "$1") <(sort -u "$2"); }
      justB()  { comm -13 <(sort -u "$1") <(sort -u "$2"); }
      bothAB() { comm -12 <(sort -u "$1") <(sort -u "$2"); }
  • by seiferteric on 9/21/21, 12:13 AM

    Cool, can't believe I didn't know about comm command. I usually like to use sets() for this type of thing with python or ruby it is easy.
  • by rstuart4133 on 9/20/21, 2:57 AM

    Or just:

        vim -d file1 file2
        :%!sort | uniq -c
        :wincmd l
        :%!sort | uniq -c