Suppose you want to make an edit in all files containing a pattern. For instance, change all '2017' to '2018'. Many suggestions exist for perl, sed, and a variety of others. The ed editor is significantly simpler, if it can be made to work.
Given a file:
$ echo 2017 > fubar
Why does this not work
$ ed fubar <<< ',s/2017/2018/g\nw\n'
6
?
$ cat fubar
2017
$
When this does.
$ printf ',s/2017/2018/g\nw\n'|ed fubar
6
7
$ cat fubar
2018
$
In the end, it would be used in a loop like this
$ for i in `grep -r -l 2018`; do ed $i <<< ',s/2017/2018/g\nw\n'; done