grep -lr "int main()" * | xargs sed -i -e 's/foo/bar/'
This will replace all occurrences of
foo
with bar
in all files recursively if they contain int main()
. E.g. int main() { int foo = 0; return foo; }
Will be changed to:
int main() { int bar = 0; return bar; }