Last Updated: February 25, 2016
·
195
· pacorro2000

Shell Output into Vi

In VI editor you can get the output of any shell command command inserted into the file you are editing by using:

:r!<command>

For example:

:r!who -r

Inserts the ouput of the command "who -r" to the file currently being edited.
This can be effectively used to copy the contents of a file to the file currently being edited ie,

:r!cat /etc/passwd

Inserts all the contents of the the /etc/passwd to the file currently being edited.