grep using input file as pattern to search other file

Sometimes we need to use another file which contains a multiple line that we want to use as input pattern

example:

You have a.txt

a
b
c
d
e

And you want to search a, c, e.

This case you can create input.txt

a
c
e

and use this command

grep -f -F input.txt a.txt

If the input txt is a list of regex you can remove the -F option.

 -F, --fixed-strings
              Interpret PATTERNS as fixed strings, not regular expressions.

Last updated