AIX Tip of the Week

AIX Tip of the Week: Running AIX Commands from vi

Audience: AIX Users

Date: March 17, 2000

First, a thank you to all IBM S80 customers for making us #1! Last Friday IDC, an outside industry analyst, reported the RS/6000 S80 outsold the Sun UE10000 by roughly three to one in 4Q99. The details can be found at the following URL.:

And now the tip:

Here are several examples of running Unix commands from inside a "vi" editing session. Running Unix commands allows you to add external data, sort and format text, spell check, and more.

! ls                   # run the ls command (displays output, but does not change the current file)
r ! date               # run the date command and insert output into the current file 
% ! fmt	               # format the text in the entire file
45,78! tr [a-z] [A-Z]  # uppercase all characters in lines 45 to 78
/abc/,/xyz/!sort       # sort the lines starting with the line containing "abc" throught the line containing "xyz"
. , $! cb              # format a C program using the cb (C Beautify) command, starting at the current line through end of the file

(Note: to run these commands, you need to be in the command mode, which is started with the [ESC]: key combination).