From the manual of grep-f file--file=fileObtain patterns from file , one per line. The empty file contains zero patterns,and therefore matches nothing. (-f is specified by POSIX.)When there are multiple lines in the file, how are the patterns specified by each line working together?Isn't there only one pattern used in each grep command?
How are multiple patterns specified in a file with `-f` to `grep` working together?
grep
When you pass multiple patterns, grep searches for lines that match at least one of the patterns. In other words, passing multiple patterns is equivalent to passing them as a single pattern combined with the or operator (| in ERE syntax (grep -E)). This is mostly useful with BRE (plain grep) and string (grep -F) pattern syntax, where the or operator is a newline which is annoying to pass as a parameter.You can pass multiple patterns by repeating the -e option, or by using the -f option with a multi-line file (or multiple times).