How to search file text for a pattern and replace it with a given value

Viewed 132392

I'm looking for a script to search a file (or list of files) for a pattern and, if found, replace that pattern with a given value.

Thoughts?

11 Answers

I am using the tty-file gem

Apart from replacing, it includes append, prepend (on a given text/regex inside the file), diff, and others.

Related