Last active
June 23, 2019 14:46
-
-
Save vbarbarosh/7794d4a48d207b463e1145e788604402 to your computer and use it in GitHub Desktop.
shell_lines_common – Show common lines in two files https://codescreens.com
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
#!/bin/bash | |
# http://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin | |
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -o nounset -o errexit -o pipefail | |
# Show common lines in two files | |
# https://unix.stackexchange.com/a/398143/121657 | |
# > Use comm -12 file1 file2 to get common lines in both files. | |
# > | |
# > You may also needs your file to be sorted to comm to work as | |
# > expected. | |
# > | |
# > comm -12 <(sort file1) <(sort file2) | |
# > | |
# > From man comm: | |
# > | |
# > -1 suppress column 1 (lines unique to FILE1) | |
# > -2 suppress column 2 (lines unique to FILE2) | |
comm -12 <(sort emails-prod.txt) <(sort emails-dev.txt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment