I want to run the following shell.wea-this is the end of the second word | vim jexit 0Which I had hoped would pipe the key strokes w (move forward a word) then e (end of the word) then a (append) then -this is the end of the second word (text) to the Vim document named j which already has words in in it.The following error occurred when I ran the shell script./root/bin/tt.sh: line 1: wea-this: command not foundVim: Warning: Input is not from a terminalI am running Ubuntu 14.04.Two types of answers will be appreciated:How to use piping to achieve this desired result.Another method by which I can use Vim commands (not ed or sed commands) to edit a text document from a shell script. 
Is it possible to pipe input to vim?
invocation
To insert the string hello on the first line of the file j, you could type in your shell the following command:vim +1 | put! ='hello' j:1 moves the cursor to the first line of the buffer:put! ='hello' pastes the string hello above the current lineTo insert the string hello and then save and quit the file:vim +1 | put! ='hello' | x jSame thing as before, we've just added the Ex command :x which saves and quit.More generally you can execute any sequence of Ex commands on a file, from an interactive shell or from a bash script, like this:vim +'Ex command1 | Ex command2 | ...' fileIf you have a lot of Ex commands, you could write them all inside a dedicated file (called for example myExCommands.vim), one command per line, and then from the shell or a script you could source it (with the Ex command :source or the short version:so) like this:vim +'so myExCommands.vim' fileEditI see you've edited your question.I think the previous answer still applies, because you can execute any normal command from Ex mode with the Ex commands :normal and :execute.For example, let's say you want to :move your cursor on the first line of the buffer (1G)move your cursor to the first non whitespace character on the line (_)move your cursor one word forward (w)move your cursor to the end of the new word (e)go into insert mode after the character under the cursor (a)insert the string hellosave and quit (:x)To do this on the file j, type from the shell:vim +execute 'normal! 1G_weahello' | x jFor more information, see::help +cmd:help :normal:help :execute