Previous Table of Contents Next


The following table describes each of the tilde escape commands.


Escape Command Description

~!cmd Causes mailx to invoke the cmd command. For example,

~!sh

starts a subshell for you. When you want to return to entering your message, type Ctrl-D. Another example is

~!ls

which lists your current directory.

~. Terminates input mode. The same as Ctrl-D.
~:mailx cmd Executes a mailx command. You can only use this command if you
~_mailx cmd entered the input mode from the command mode (you were reading mail).
~? Displays a brief summary for the tilde escape commands.
~A Inserts the value of the Sign variable into your message. Usually Sign is set to a signature or sign-off type string. For example, if you had

set sign="Sincerely,"

in your .mailrc file and you type ~A during input mode, mailx inserts "Sincerely" in you text.

~a Same as ~A except inserts the value of the sign variable.
~b name list Add the names in name_list to the blind carbon copy (Bcc) list. The recipients of the message are not informed of who received blind copies of the message.
~c name list Add the names in name_list to the carbon copy (Cc) list. The recipients of the message are informed who received carbon copies of the message.
~d Reads the contents of the dead.letter file into your message. See the description of the DEAD variable. The dead.letter file is created by mailx when it is unable to send the message or it is interrupted. The incomplete message is stored in dead.letter.
~e Invokes an editor so you can edit the message you are sending. The editor used depends on the value of the EDITOR variable.
~f msglist Inserts the messages specified in msglist into your current message. This is considered forwarding the message on to another user. You can only use this command if you entered the input mode from the command mode (you were reading mail).
~h Causes mailx to prompt you for the Subject, To, Cc, and Bcc fields. If a field already contains a value, you can edit it as if you just entered the value.
~i variable Inserts the value of the specified variable into your message. For example,

~i Sign

is equivalent to the ~A command. It inserts the value of the "Sign" variable.

~m msglist Inserts the messages specified in the msglist into your current message. The inserted message text is indented one tab stop. You can only use this command if you entered input mode from command mode (you were reading mail).
~p Displays the message you are currently typing.
~q Simulates a QUIT signal; causes mailx to be interrupted. The input session is aborted and mailx saves the message to the dead.letter file. If no text has been entered, mailx does not save to dead.letter. See the DEAD variable description.
~r filename Reads the specified file into the message.
~< filename
~< !cmd Reads the standard output of the command cmd into the message.
~s string Inserts string into the Subject field.
~t name list Adds the specified names in name list to the To field.
~v Invokes the editor defined by the VISUAL variable. The default is the vi editor.
~w filename Writes the message you have entered so far to the file filename.
~x Exits mailx like the ~q command except the message is not saved to the dead.letter file.
~|cmd Sends (pipes) the message you have typed to the command cmd. If the shell_cmd exits with a return code of 0 (successful), the standard output of the cmd replaces the message.

BSD (Berkeley)
The BSD mail program does not support the following tilde commands.
~A
~a
~i
~r filename
~< filename
~< !shell_cmd
~x

READING MAIL

To read the mail stored in your mailbox you simply run mailx without any arguments. For example,

$ mailx

If you do not have any mail to read, mailx returns a message stating that fact. If you have mail, a numbered list of messages is displayed on your screen and mailx enters command mode. For example,

     $ mailx
     mailx version 2.2 9/9/88.  Type ? for help.
     "/usr/mail/mylogin": 2 messages 2 unread

     >N  1  bill   Tue Apr 12 08:31  5/134  "cabling problems"
      N  2  nancy  Tue Apr 12 10:03  4/98   "lunch in the break area"

Each line in the list contains the status of the message (New, Old), the sender of the message, delivery time, the size in lines/bytes, and the subject. The current message is preceded by a > (greater than sign). Some of the messages will have subject fields, others may not.

After the list of messages is displayed you are prompted with a ? (question mark). You can type any of the command mode commands to manipulate the list of messages. Some examples are:

?2 Read message number 2.
?q Quit mailx. The read messages are saved to your mbox file. Messages that you have not read are left in your mailbox file (/usr/mail/mylogin, /usr/spool/mail/mylogin on BSD).
?? Enter a question mark for a brief summary of commands (the help screen).


Previous Table of Contents Next