Home > Linux > Finding Files Containing Text

Finding Files Containing Text

October 13th, 2006 Leave a comment Go to comments

When 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
...
Categories: Linux Tags:
  1. No comments yet.
  1. No trackbacks yet.