Software >> OS >> Unix >> Utilities >> vi >> Examples of how to use vi within a script to edit a file

(1)  Edit file named test.txt and ad the string " world" at the end and then quit and save

$ vi test.txt -c ':%s/$/ world/' -c ':wq!'