Harnessing Other UNIX Commands to Work in vi

Earlier, you saw how to apply sed to some or all of the lines of the file. You can use that same technique to use other UNIX commands to manipulate lines in vi.

Checking Other UNIX Commands While in vi

While you are editing in vi, you might want to look up some information by running other UNIX commands or pipelines. You can do this from vi Command mode, by entering this:

:! cmd

Replace cmd in the preceding command with the desired UNIX command or pipeline you want to run. The output from that command will appear on your screen. At the end, it will prompt you to press the Enter key. Then you will be back in vi Command mode, ready to do more editing of your file. You saw this process in the preceding ...

Get Practical UNIX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.