Created
January 18, 2018 10:20
-
-
Save drewmccormack/31f217de744049eaf4e102ccc7b66ee9 to your computer and use it in GitHub Desktop.
Common set operations to perform on email lists. Assumes one email per line, and handles case insensitivity.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter two file names as arguments. | |
# Will print out the ones that appear in both files. | |
# This is a set intersection. | |
emails-common-to-both () { | |
comm -12 -i <(sort -u -f "$1") <(sort -u -f "$2"); | |
}; | |
# Enter two filenames. | |
# Will print emails from first that don't appear in second. | |
# This is like a set subtraction. | |
emails-unique-to-first () { | |
comm -i -23 <(sort -u -f "$1") <(sort -u -f "$2") | |
}; | |
# Enter two filenames. | |
# Creates the union of the two (case insensitive). | |
emails-combined-from-both () { | |
sort -u -f "$1" "$2" | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment