01/26/2023 13:19 | Category: linux

Tags: greptext_search

finding text with line numbers using recursive grep

A helpful command that I put together to find some information using grep when trying to find common lines (to change) across different projects.

grep -rnI "my search string pattern here" --include="*.<my file extension here>"

The below example would find all references to the Terraform module autotune across my projects. This returns the line number and file name.

grep -rnI "git::https://github.com/mattdood/autotune" --include="*.tf"

Additionally, we could apply a sort to this by piping, though this removes the color output.

grep -rnI "git::https://github.com/mattdood/autotune" --include="*.tf" | sort