I need to make a script file that reads two files and prints out common lines between them. I know that both the files are the same number of lines and each line only contains one word.
File 1:
Blue
Red
Orange
Green
Yellow
Blue
File 2:
Blue
Green
Red
Purple
Yellow
Blue
Expected output:
Blue
Yellow
Blue
So in the example Red and Green appear in both files, however they are not on the same line in each file so they are ignored.
Have tried using awk, grep and comm but couldn't get them to work.
Trying to find the solution that takes the shortest amount of time to process.