Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives.

It is suggested that you use Python instead of shell script to manipulate text files!

  1. Union lines in 2 files.

     :::bash
     comm f1 f2

    Or you can use

     :::bash
     cat f1 f2 | sort -u | uniq -u
  2. Show symmetric difference

     :::bash
     comm -3 file1 file2
  3. Show difference of 1 and 2

     :::bash
     comm -23 file1 file2

Note that lines in files must be sorted first if you use the command comm. To sort lines in a file, you can use the following command.

:::bash
sort file -o file