grep -f somefile or
grep --file=somefile will find all lines that match one of the patterns listed in
somefile is empty, nothing will match. With
grep -v you list lines that do not match.
grep -f /dev/null matches nothing and
grep -v -f /dev/null matches everything.
Experiment: Now try it with
% echo blank | grep -f /dev/null % echo bingo | grep -v -f /dev/null bingo
Outcomes: Indeed I do get
bingo (and only that) on one machine that has
unix1% grep --version grep (GNU grep) 2.20
But I do not get
bingo !?!? on another machine, this time with
unix2% grep --version grep (BSD grep) 2.5.1-FreeBSD unix2% uname -rs Darwin 14.0.0
Question: is there some leeway in the spec of
grep? Some legalese that I missed? Or is
grep (BSD grep) 2.5.1-FreeBSD buggy? The sure thing is that I spent two hours finding what went wrong when porting my scripts from unix1 to unix2 ...