Recursive Grep by file type

ripgrep is a recursive searching utility for searching through files for contents, much like grep does. In this example, I use ripgrep or rg to recursively search for any file in my django application that contains the work import and return the file and what is imported.

The -t flag is used to specify python files.

rg "import" -t py
3:import os
4:import sys
10:        from import execute_from_command_line
13:            "Couldn't import Django. Are you sure it's installed and "

10:import os
12:from django.core.wsgi import get_wsgi_application

10:import os
12:from django.core.asgi import get_asgi_application

1:from django.shortcuts import render
2:from django.views.generic import TemplateView, DetailView, ListView
3:from .models import *
5:from django.db.models import Q

Note that the output returns both the file, line number of the import and the import full text