Last night, I have several files containing the same text and I wanted that text to be replaced. I used perl one liner to do the job and I thought it may be useful for someone else so here it is:
perl -e “s/text/replacewith/g;” -pi.orig *.txt
This is going to save a backup of the files with .orig extension and do the replace. If you don’t want backup, then remove the .orig from the line.
Also, if you want to replace text in all files in a directory, then use:
perl -e “s/text/replacewith/g;” -pi.orig $(find . -type f)