UNIX shell commands

UNIX shell commands

You can run UNIX commands and see their output without leaving vi. You can also insert the output of a UNIX command into the file you that are editing.

To run a single UNIX command use the command:

   :!UNIX_command

You can start a shell from within vi and use it as you would your usual UNIX environment, then exit the shell and return to vi.

To start up a shell enter the command:

   :sh

The type of shell that is started is determined by the $SHELL variable. You can specify that some other shell is to be started by setting the vi shell option.

Return to using vi by entering the command exit or Ctrl-D.

To insert the output from a UNIX command into a file, immediately after the cursor:

   :r!command

For example, this facility would be very useful if you were using vi to document a UNIX command and you wanted to include examples of the output from this command.


[Home] [Search] [Index] This site maintained by unixhelp@math.rutgers.edu
This page was last updated on September 05, 2006 at 10:30 am and is maintained by webmaster@math.rutgers.edu.
For questions regarding courses and/or special permission, please contact mclausen@math.rutgers.edu.
For questions or comments about this site, please contact help@math.rutgers.edu.
© 2012 Rutgers, The State University of New Jersey. All rights reserved.