UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: eqnChapter 2
UNIX Commands
Next: Reference: expr


ex [options] files

A line-oriented text editor; a superset of ed and the root of vi. See Sections 8 and 9 for more information.



Begin edit session by executing the given ex command (usually a search pattern or line address). If command contains spaces or special characters, enclose it in single quotes to protect it from the shell. For example, command could be ':set list' (show tabs and newlines) or /word (search for word) or '$' (show last line). (Note: -ccommand was formerly +command.)


Run in LISP mode for editing LISP programs.


List filenames that were saved due to an editor or system crash.

-r file

Recover and edit file after an editor or system crash.


Edit in read-only mode to prevent accidental changing of files.


Suppress status messages (e.g., errors, prompts); useful when running an ex script. (-s was formerly the - option.)

-t tag

Edit the file containing tag, and position the editor at its definition (see ctags for more information).


Invoke vi. Running vi directly is simpler.


Verbose; print non-terminal input on standard error. Useful for tracking shell scripts running ex.


Supply a key to encrypt or decrypt file using crypt.


Same as -x but assume that file began in encrypted form.


Either of the following examples will apply the ex commands in exscript to text file doc:

ex -s doc < exscript
cat exscript | ex -s doc

Previous: Reference: eqnUNIX in a Nutshell: System V EditionNext: Reference: expr
Reference: eqnBook IndexReference: expr

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System