Given the following ed script,$ cat helloworldahelloworld.,n,s,o,O,g,nQI would like to obtain somehow the interactive output$ edahelloworld.,n1   hello2   world,s,o,O,g,n1   hellO2   wOrldQ$instead of the expected$ cat helloworld | ed1   hello2   world1   hellO2   wOrld$Is that possible, maybe using a third-party utility? Thanks in advance!Edit: I guess I should add some motivation. I would like to produce some sample ed sessions, and probably save them with script(1). If this process is performed live, any modifications would basically imply typing the whole tutorial again (bad) or alternatively figuring out the output, potentially based on a long editing session (worse).
Echoing stdin when running an ed(1) script
shell;stdin;ed
Well, after monkeying around with it, this is what I'd use: awk '{ print; system(sleep 0) }' edscript | tee /dev/tty | edor, without tee:awk '{ print >/dev/stderr; print | ed; system(sleep 0) }' edscriptIf print >/dev/stderr doesn't work on your system you could use print | cat >&2.  With gnu sed:sed -u -n -e 'p;w /dev/stderr' -e 's|.*||e' edscript | edAnother way that works just as well:Use split to split your edscript on each line:split -l1 edscriptthis will produce pieces like xaa, xab...xah.You could then use the pieces like this:for i in x*; do awk '{ print >/dev/stderr; print }' $i; done | edorfor i in x*; do sed -n -e 'p;w /dev/stderr' $i; done | edto get the expected result. Then you rm x*...