Skip to main content
10 of 12
deleted 373 characters in body
don_crissti
  • 85.6k
  • 31
  • 234
  • 262

Well, after monkeying around with it, this is what I'd use:

 awk '{ print; system("sleep 0") }' edscript | tee /dev/tty | ed

or, without tee:

awk '{ print >"/dev/stderr"; print | "ed"; system("sleep 0") }' edscript

If print >"/dev/stderr" doesn't work on your system you could use print | "cat >&2".
The system("sleep 0") is there just to break the stream input to pipe. You could equally use something else as long as it doesn't produce any output and comes from a different source, e.g. system("date >/dev/null") or system("echo BREAK >/dev/null").


Another way that works just as well:
Use split to split your edscript on each line:

split -l1 edscript

this will produce pieces like xaa, xab...xah.
You could then use the pieces like this:

for i x*; do cat $i | tee /dev/tty; sleep 0; done | ed

and get the expected result:

a
hello
world
.
,n
1   hello
2   world
,s,o,O,g
,n
1   hellO
2   wOrld
Q
don_crissti
  • 85.6k
  • 31
  • 234
  • 262