title: Search file contents recursively when know where in file
body: <p>I am interested in efficiently searching files for content using bash and related tools (eg sed, grep), in the specific case that I have additional information about where in the file the intended content is.  For example, I want to replace a particular string in line #3 of each file that contains a specific string on line 3 of the file.  Therefore, I don't want to do a recursive <code>grep -r</code> on the whole directory as that would search the entirety of each file, wasting time since I know that the string of interest is on line #3, if it is there. This full-grep approach could be done with <code>grep -rl 'string_to_find_in_files' base_directory_to_search_recursively</code>.  Instead I am thinking about using <code>sed -i ".bak" '3s/string_to_replace/string_to_replace_with' files</code> to search only on line #3 of all files recursively in a directory, however sed seems to only be able to take one file as input argument.  How can I apply sed to multiple files recursively?  <code>find -exec {} \;</code> and <code>find -print0 | xargs -0</code> seem to be very slow.. Is there a faster method than using find?  I can achieve the desired effect very quickly with <code>awk</code> but only on a single directory, it does not seem to me to be recursive, such as using <code>awk 'FNR==3{print $0}' directory/*</code>.  Any way to make this recursive?  Thanks.</p>