How can I use vi command in shell script?
<p>I am using CentOS 6.7</p>

<p>I want open test.txt by vi and insert text "hihi"
then save and quit from vi.</p>

<pre><code>#! /bin/bash

vi test.txt &lt;&lt; 'END'
i
hihi
press ESC
w
q
END
</code></pre>

<p>The result like this</p>

<pre><code>Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
</code></pre>

<p>How can I fix it?</p>