[Return to Library] [Contents] [Previous Chapter] [Next Chapter] [Index] [Help]


E    Using Escape Commands in Your mailx Session

There is a special set of commands, called escape commands or escapes, that perform functions while you are in the process of writing a message.

You use an escape command by entering it on a line by itself, with a tilde (~) as the very first character. The tilde is called an escape character because it signals mailx that an escape command follows. If you want to type a real tilde as the very first character on a line in your message, you must type two tildes.

Table E-1 describes the escape commands.

Table E-1: Escape Commands in mail

Command Description
~~ Allows the user to enter the tilde (~) character in the body of the mail message.
~!command Executes the shell command you enter.
~? Prints a brief summary of escape commands.
~:command
~_command
Executes the specified mail command. This is useful for performing housekeeping tasks such as redisplaying a message. For example, entering ~:10 selects and displays message number 10 just as if you had entered its number at the & mail prompt.
~a Inserts the string set in sign into the mail message.
~A Inserts the string set in Sign into the mail message.
~b address_list Inserts the specified names in address_list into the Bcc: (blind carbon copy) list.
~c address_list Adds the specified names to the Cc: (carbon copy) list.
~C Dump core.
~d Includes the file named dead.letter, in your home directory, into the message.
~e Invokes the editor specified by the EDITOR mail variable to edit the message.
~f [message_list] Reads the current message or the specified messages into your message.
~F [message_list] Similar to ~f with the difference that all headers will be included regardless of any discard, ignore, or retain commands.
~h Edits the message header fields. This command displays the fields one at a time so you can alter them by adding text to the end, by using the Delete key, or by pressing Ctrl/u to erase the entire field and then retyping it. Use this command with caution.
~i string Insert the value of the named variable into the mail message. For example: ~a is equivalent to ~i sign.
~m [message_list] Includes the current message or the specified messages, shifted one tab stop to the right. This is useful to set off messages you are forwarding as part of your new message.
~M [message_list] Similar to ~m with the difference that all headers will be included regardless of any discard, ignore, or retain commands.
~p Displays the message you are composing on your terminal. This is useful to see that the message looks the way you want it to and that it includes the right subject heading and lists of recipients.
~r file
~< file
~<!shell_cmd
Reads the named file into the mail message. If the argument begins with an exclamation point (!), the rest of the string is taken as an arbitrary system command and is executed with the standard output inserted into the mail message.
~q
~Q
Aborts the current message as if you press two Ctrl/C interrupts.
~r file Includes the named file in your message.
~s subject Makes subject the new subject heading, replacing the previous heading.
~t name... Adds the names to the To: list of your message.
~v Invokes the editor specified by the VISUAL mail variable to edit the message.
~w file Writes the message to the named file.
~|command
~^
Pipes the message through the named command. This is useful to make global changes in the message; for example, if you are including a message in your new message you can use the sed editor to prefix each line with an angle bracket and a space by using the following command:
~|sed 's/^/> /'
You can then add your own text; the result will look like this:
> This is the text of the message
> you have included.
>
This is the text you add yourself.