Bash: any command to replace strings in text files?

Posted by mikez302 on Stack Overflow See other posts from Stack Overflow or by mikez302
Published on 2010-05-18T18:58:02Z Indexed on 2010/05/18 19:00 UTC
Read the original article Hit count: 207

I have a hierarchy of directories containing many text files. I would like to search for a particular text string every time it comes up in one of the files, and replace it with another string. For example, I may want to replace every occurrence of the string "Coke" with "Pepsi". Does anyone know how to do this? I am wondering if there is some sort of Bash command that can do this without having to load all these files in an editor, or come up with a more complex script to do it.

I found this page explaining a trick using sed, but it doesn't seem to work in files in subdirectories.

© Stack Overflow or respective owner

Related posts about bash

Related posts about text-processing