Created
February 13, 2023 10:57
-
-
Save tuananh/8c981cdd22f9a7b993899e69f5ccf83d to your computer and use it in GitHub Desktop.
Bash: intersection of 2 lists
This file contains hidden or 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
export LIST1=a b c d | |
export LIST2=b c d e f | |
INTERSECTION=($(comm -12 <(for X in "${LIST1[@]}"; do echo "${X}"; done|sort) <(for X in "${LIST2[@]}"; do echo "${X}"; done|sort))) | |
echo ${INTERSECTION[@]} | |
# b c d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment