Search and replace text in matching files on the command line.

After a bit of searching and trying a few different methods, I’ve settled on the following commands to find and replace a text string in all files that match the search string identified through grep.

Here’s the full command (adjust the values of searchtext, matchtext and replacetext accordingly).