Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

how to search the results of grep for an expression (e.g. find if all uses of “logging” are “logging.info”)

Given the output of grep -Rn "import logging" was a list of files which import logging module, I want to see what are the uses of said files . Specifically, I want to see if logging was imported to use logging.info/error or other things from that module.

How can I use grep + pipes to achieve that? (or an even better solution for that, if there is)

What I thought of is grep -rn "import logging" and then for each file grep it with grep -e "logging.info" -e "logging.error" but that seems a long and excruciating way

This is a toy example of my output:

a/x/c/q.py:23:import logging
a/x/c/z.py:24:import logging
a/x/b/scripts/y.py:37:import logging
a/x/b/scripts/y.py:26:import logging
a/x/b/scripts/y.py:41:import logging

Now, I want to see if any og this files is using logging in a way other than logging.info / logging.error / import logging

Comments