How to execute external commands in Line Mode

Being able to execute shell commands from within the vi editor is sometimes quite useful. The following table lists some examples of shell command execution from Line Mode:

Line Mode command

Description

:! <shell command>

Executes a shell command (press Enter to return to vi editor)

:!wc %

Executes the wc command on the file opened in vi editor (% represents the file currently being edited)

:sh

Temporarily returns to the shell prompt (type Exit to return to vi editor)

:r !<shell command>

Reads the output from a shell command into the opened file at the current cursor position

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.183.1