How to execute the vim commands through shell script

Viewed 5276

Hi I have a situation as

I have a writing a shell script where I have to pass input to the vim.

Explaining in detail

Here I have already written shell script that I cannot changed. Here is the code for it.

 sudo vim /mnt/etc/{hosts,hostname,ports}

due to this hosts file is opened we can go manually next to the hostname file by :n and similar for the ports file.

But I have to perform same operation from my .sh file. Also I have to edit the ports file and after completing it I have to save and quite it through :wq command.

How can I do it?

1 Answers
Related