Search for string inside many files

Combine find, its -exec argument and grep to search inside many files recursively and display the file path in results.

Here I’m searching inside the directory modules/ for any files with the extension .tf that contain the string “mode =”.

$ find modules/ -name "*.tf" -type f -exec grep -H 'mode =' {} \;
modules/gitlab-base-ignition/main.tf:  mode = 0755
modules/gitlab-base-ignition/main.tf:  mode = 0755
modules/gitlab-base-ignition/main.tf:  mode = 0755
modules/gitlab-base-ignition/main.tf:  mode = 0644
modules/network-ignition/main.tf:  mode = 384