Skip to content

Instantly share code, notes, and snippets.

@hfs
Created April 30, 2014 18:10
Show Gist options
  • Save hfs/f68a188082ba71d5cd7c to your computer and use it in GitHub Desktop.
Save hfs/f68a188082ba71d5cd7c to your computer and use it in GitHub Desktop.
Merge two files with common lines using `diff`

First file:

A
B
C
D

Second file:

C
D
E
F

Result:

A
B
C
D
E
F
#!/bin/bash
diff --changed-group-format='%<%>' --unchanged-group-format='%<' 1.txt 2.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment