You could try with the following format
grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'
The example would be :
grep -rl 'windows' ./ | xargs sed -i 's/windows/linux/g'
This will search for the string
windows in all files relative to the current directory and replace 'windows' with
linux for each occurrence of the string in each file.
Additional Note from comment : The forward slash '/' delimiter in the sed argument could also be a different delimiter (such as the pipe '|' character). The pipe delimiter might be useful when searching through a lot of html files if you didn't want to escape the forward slash.
In addition to that you could try kev method
sed -i 's/foo/bar/g' *
Occurrences of "foo" will be replaced with "bar".