I am a first-timer at programming, and I'm trying to find the intersection of two text files.
file1.txt
a a
a b
a a
a c
file2.txt
a a
I want to get the result below in file1
(lines in file2
that are in file1
)
a a
a a
I try to use grep
command in Linux but I don't know how to do it.
I saw something similar here https://stackoverflow.com/a/36591385/4053813
< file1 xargs -I % grep -xF '%' file2
Edit: As pointed out by @Julien Lopez I added -xF options to grep command.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments