Help direct stdout to grep!
Hi folks,
Hoping someone out there can help a recent Linux transplant.
I am unable to replicate a grep command I use in Linux quite frequently. I would like to take patterns from stdout and pass them to grep to search file foo for those patterns. In linux, I would do the following:
cat patterns | grep -f - foo
If foo contained any patterns, those lines of foo would be happiily printed to stdout. However, this exact command in osx produces the following error:
grep: -: No such file or directory
It looks to me like grep does not recognize the '-' as a sign to take the list of patterns from the piped cat command. Googling for a while now, and can't figure out the problem. In fact, this post suggests there is no problem! Oy.
Please help!
MacBook Air, OS X Mountain Lion (10.8.4)