Skip to main content
11 of 12
deleted 182 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".


With gnu sed:

sed -u -n -e 'p;w /dev/stderr' -e 's|.*|date|e' edscript | ed

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 in x*; do awk '{ print >"/dev/stderr"; print }' $i; done | ed

or

for i in x*; do sed -n -e 'p;w /dev/stderr' $i; done | ed

to get the expected result. Then you rm x*...

don_crissti
  • 85.6k
  • 31
  • 234
  • 262