H
H
hofix2020-09-17 09:25:31
linux
hofix, 2020-09-17 09:25:31

How to output lines in file 1 if there is a line match with file 2?

How to output lines in file 1 if there is a line match with file 2?

File 1
1: Vasya
2: Petya
3: Kolya
4: Ivan

File 2
Vasya
Igor
Ivan

Required output:
1: Vasya
4: Ivan

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-09-17
@hofix

fgrep -if ./file2.txt ./file1.txt
-i- case-insensitive search (if necessary)
-f- get a list of strings to search from the specified file, line by line

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question