I want to run the following grep from within a Ruby script:
grep "word1" file1.json | grep -c "word2"
This will find the number of lines in the file with both words appearing. I could do this with Ruby regex, but it seems that Unix grep is much faster. So my question is how do I run this command within a script and return the result back to a Ruby variable?
I'd love to hear alternative solutions that don't use grep, if they are as fast or even faster.