to recursively find a string in multiple files under a directory grep -R 'string' directory to recursively find a string in multiple files under a directory and then replace the string with something else grep -R 'string1' directory | xargs sed -i 's/string1/string2/g'