I am interested in mastering the art of using ex
from the command line (vi -esc <commands>
/ ex -sc <commands>
). I got the basics worked out, but one thing eludes me:
How do I add text using insert mode?
Let's say I want to add text at the end of the file. In interactive ex, I would do:
$ ex file.txt
:normal! G
$a
foo
.
x
But if I enter that same sequence as -c
command line option when invoking ex
, I get stuck on the interactive ex
command line, and if I enter x
from there, my file remains unchanged.