Is there such a thing as cached grep?
It sounds like you really need a pipeline. Grep handles this use case well, allowing you to re-filter previously filtered results by accepting data on standard input.
Search for "bar" in lines that have "foo." grep foo * | grep bar Search for "baz" in lines that don't have "quux." grep -v quux * | grep baz
source to share