ex - Use the ex text editor

Format

ex [-BelRrsv] [+command] [-c command] [-t tag] [-w size] [-W option[option] ... [file ... file ...]

Description

ex is the line-editor mode of the vi text editor.

Options

The ex internal commands are described in vi. It supports the following options:
+command
Begins the editing session by running the specified editor command. To specify multiple commands, separate them with a vertical bar (|).
-B
Disables the automatic conversion of tagged files. This option is ignored if the filecodeset or pgmcodeset options (-W option) are specified.
-c command
Begins editing by executing the specified editor command. To specify multiple commands, separate them with a vertical bar (|). command can be any ex command except those that enter input mode, such as insert or append.
-e
Invokes ex. This option is intended for use with vi.
-l
Sets LISP mode. The ( and ) commands use blocks of LISP code as their context rather than sentences.
-r
Recovers named files after an editor or system fails. If you do not specify a file argument, ex lists all recoverable files and then exits.

When using ex -r to recover a file that was being edited with automatic conversion, the file must also be recovered with automatic conversion enabled when writing the data back to the original tagged text file. Likewise, if explicit conversion was being used when editing the file (by using the -W filecodeset or -W pgmcodeset options), the same options must be specified when writing the recovered data back to the original file. Failure to do either of these might result in incorrectly coded character data being written to the file when you save the recovered version.

-R
Sets read-only mode.
-s
Suppresses all interactive feedback (quiet mode). This option is for batch mode operation; ex assumes that the terminal cannot display text and ignores the value of TERM. ex also ignores all startup files and ignores the value of EXINIT.
-t tag
Edits the file containing the specified tag and sets the virtual position in the edit buffer to point of definition for the tag.
-v
Invokes vi.
-w size
Sets the option variable window equal to size.
-W option[,option]...
Specifies z/OS-specific options. The option keywords are case-sensitive. Possible options are:
filecodeset=codeset
Performs text conversion from one code set to another when reading from the file. The coded character set of the file is codeset. codeset can be a code set name known to the system or a numeric coded character set identifier (CCSID). Note that the command iconv -l lists existing CCSIDs along with their corresponding code set names. The filecodeset and pgmcodeset options can be used on files with any file tag.

If pgmcodeset is specified but filecodeset is omitted, then the default file code set is ISO8859-1 even if the file is tagged with a different code set. If neither filecodeset nor pgmcodeset is specified, text conversion will not occur unless automatic conversion is enabled or the _TEXT_CONV environment variable indicates text conversion. For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.

If filecodeset or pgmcodeset is specified, then automatic conversion is disabled for this command invocation and the -B option is ignored if it is also specified. For more information about automatic conversion, see Converting files between code pages in z/OS UNIX System Services Planning.

When specifying values for filecodeset, use the values that Unicode Service supports.

pgmcodeset=codeset
Performs text conversion from one code set to another when reading from the file. The coded character set of the program (command) is codeset. codeset can be a code set name known to the system or a numeric coded character set identifier (CCSID). Note that the command iconv -l lists existing CCSIDs along with their corresponding code set names. The filecodeset and pgmcodeset options can be used on files with any file tag.

If filecodeset is specified but pgmcodeset is omitted, then the default program code set is IBM-1047. If neither filecodeset nor pgmcodeset is specified, text conversion will not occur unless automatic conversion is enabled or the _TEXT_CONV environment variable indicates text conversion. For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.

If filecodeset or pgmcodeset is specified, then automatic conversion is disabled for this command invocation and the -B option is ignored if it is also specified. For more information about automatic conversion, see Converting files between code pages in z/OS UNIX System Services Planning.

The only supported values for pgmcodeset are IBM-1047 and 1047.

Examples

  1. To edit or browse a file containing UTF-8 characters using the ex editor, assuming that:
    • The file is untagged and you do not want to tag it or enable automatic conversion, and
    • You cannot alter the tag (for example, you are browsing an untagged public file or a read-only file)
    issue:
    ex -W filecodeset=UTF-8,pgmcodeset=IBM-1047 myUtf8File
  2. To edit or browse a file containing EBCDIC characters using the ex editor, assuming that automatic conversion has been enabled but the file is incorrectly tagged as ASCII, issue:
    ex -B myMisTaggedFile

Localization

ex uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

Environment variables

ex uses the following environment variable:
_TEXT_CONV
Contains text conversion information for the command. The text conversion information is not used when either the -B option or the filecodeset or pgmcodeset option (-W option) is specified. For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.

Exit values

0
Successful completion.
1
Failure due to any of the following reasons:
  • The code set is not valid.
  • Could not turn off automatic conversion.
  • Could not perform requested text conversion.
2
Failure due to any of the following reasons:
  • Unknown command-line option.
  • Missing or incorrect num in an -n option.

Portability

POSIX.2 User Portability Extension, X/Open Portability Guide, UNIX systems.

The -B, -e, -W, and -x options are extensions of the POSIX standard.

Related information

ed, vi