I was reading Count number of lines of output from previous program and found it helpful. However, while
$ grep -i [pattern, file] | tee >(wc -l)
gives me a nice output of the grep lines and the number of matches, I want to ask if anyone knows how to save the number of matches to a variable in my script. I want to output it within a string with more readable formatting.