Skip to content

Instantly share code, notes, and snippets.

@uncogeek
Last active February 3, 2026 15:21
Show Gist options
  • Select an option

  • Save uncogeek/08de086f2adf9977ea52bed21ca44ca2 to your computer and use it in GitHub Desktop.

Select an option

Save uncogeek/08de086f2adf9977ea52bed21ca44ca2 to your computer and use it in GitHub Desktop.
searcher.py
import os
root_dir = r"C:\dev\" # change this where to search
needle = "Your-String" # what you search for
for dirpath, dirnames, filenames in os.walk(root_dir):
for filename in filenames:
if filename.lower().endswith(".php"):
full_path = os.path.join(dirpath, filename)
try:
with open(full_path, "r", encoding="utf-8", errors="ignore") as f:
for lineno, line in enumerate(f, start=1):
if needle in line:
print(f"{full_path}:{lineno}: {line.strip()}")
except Exception as e:
print(f"Could not read {full_path}: {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment