-f option specifies a file where grep reads patterns. That’s just like passing patterns on the command line (with the
-e option if there’s more than one), except that when you’re calling from a shell you may need to quote the pattern to protect special characters in it from being expanded by the shell.
-P, if any, tells grep which syntax the patterns are written in. With no argument, grep expects basic regular expressions; with
-E, grep expects extended regular expressions; with
-P (if supported), grep expects Perl regular expressions; and with
-F, grep expects literal strings. Whether the patterns come from the command line or from a file doesn’t matter.
Note that the strings are substrings: if you pass
a+b as a pattern then a line containing
a+b+c is matched. If you want to search for lines containing exactly one of the supplied strings and no more, then pass the
I had the same error, not solved with the good answer from @gilles.
Looking closer in the input file, I found 2 newlines at the end.
Without these, success, needed only: grep -i file_pattern_input file
(GNU grep 3.1, Input file more than 5000 records, matching/pattern file 2536, I knew all the 2536 have to be in the file. With newlines got all lines of the file and without only the 2536 matching lines)