Wednesday, August 29, 2007

Tip for the day: 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!

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.

No comments: