Finding Files Containing Text
October 13th, 2006 Posted in LinuxWhen making modifications to configuration files I like to tag each line with my initials. This way I can keep track of and be able to reverse the changes if needed. The issue becomes remembering all the files that I have modified. Using a combination of the grep and find commands it is quite easy to do.
Run this in the directory to search replacing the “string to find” with the text you are looking for.
find . -type f - exec grep -l "string to find" {} \;
Example
find /etc -type f -exec grep -l "XXX" {} \;
/etc/ssh/sshd_config
/etc/vsftpd/vsftpd.conf
...