I am working with a Korn shell. There is a log file which is continuously updating. I need to update this file and insert one character in it. I am writing a shell script for it. Can anyone suggest me how I can do it through script? I need to open and close that file using vi editor through script. Please suggest a way for it.
Here are the commands I use when I edit that file: vi my_file Press ‘E/e’ (to start edit) Press ‘i’ (to insert) Press ‘F’ (to insert missing F) Press: Esc -> : -> wq! -> [Enter] -> y -> [Enter]*
I need to insert one F at the beginning of first line in this file. Please can anyone suggest me how I can do it through vi editor?. I cant use any other editor like 'sed' because that file is continously updating.
viis a "visual" editor. It's intended to be used interactively, by a human looking at a terminal and entering commands; that's what "visual" means.The script-driven equivalent to
viisex. (Often,exis actually provided by yourvipackage, or even the same executable).If you can write something in
vi's command mode that will do what you want, you can feed that as a script toex.An example, tested against Apple's BSD
ex:An example tested against the
exshipped withvim:Alternately, without using
viorexat all: