If you're on a mac then
grep should already be installed. Just in case though, you can install the tool via;
brew install grep
On many linux distributions it should also already be installed.
grep command can be used to filter through general stdout from the terminal. But
in particular we will use it to query the installed python packages via
You can use it to find the installed version of pandas via;
pip freeze | grep pandas
You can also use it to find any packages that contain the substring
pip freeze | grep num
You should be aware that grep is case sensitive. That means that these two commands should be expected to yield different outputs.
pip freeze | grep Sphi
pip freeze | grep sphi
If you want to run the command independant of capitalisation, you need to add the
pip freeze | grep -i sphi
Finally, you should remember that the standard regex
| character (which means "or") needs
to be escaped. You typically don't want to search for the string
"num|sci". Instead, you'd
want grep to search for
"sci". The following command shows an example;
pip freeze | grep -i 'num\|sci'
Back to main.