Skip to content

Instantly share code, notes, and snippets.

@H-Max
Last active January 13, 2021 11:14
Show Gist options
  • Save H-Max/1324427c0411f8b76946931ed98d9666 to your computer and use it in GitHub Desktop.
Save H-Max/1324427c0411f8b76946931ed98d9666 to your computer and use it in GitHub Desktop.
One liner to compare 2 files and keep only the difference
# Unique lines only (does not work if lines are present more than once in any of the 2 source files)
comm -13 <(head -n 1 a.txt && tail -n +2 a.txt | sort) <(head -n 1 b.txt && tail -n +2 b.txt | sort) > compare.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment