The mailx program has a large set of commands, some of which are described in Appendix D and Appendix E. The commands in Table F-1 can help you to use the mailx environment more effectively. The mailx(1) reference page lists some other commands that are useful only under special circumstances.
Command | Description |
= | Echoes the number of the current message. |
# | Allows the user to write comments in mail script files. |
!command | Executes the shell command you enter. |
-[n] | Selects and displays the previous message or the nth previous message. For example, -4 backs up four messages. |
alias
alias alias alias alias name... group |
With no arguments, lists the current aliases. With one argument, displays only that alias. With two or more arguments, creates an alias with the first argument as its name and all subsequent arguments as the members of the alias. The group command is an alternate for alias. |
alternates [alternate_list] | Informs mailx that the addresses listed in alternate_list refer to the user. If no alternate_list is specified in the command, the command displays the current list of alternates. |
chdir
path
cd path |
Changes your current directory to the pathname specified, as if you had executed the cd shell command except that the directory you specify with chdir prevails only while you are in the mail environment. |
copy
[message_list]
file
co [message_list] file |
Copies the current message or the specified messages into a file. If file exists, the messages are appended. This command works like save except that it does not mark copied messages for deletion when you quit from mailx. |
Copy [message_list] | Saves the specified messages in a file whose name is derived from the author of the first message in the message_list. This command will not mark the messages as being saved. Otherwise equivalent to the Save command. |
delete
[message_list]
d [message_list] |
Deletes the current message or the specified messages. You can use the undelete command to recover messages you have accidentally deleted. |
discard [field_list] | Identical to the ignore subcommand. |
dp
dt |
Deletes the current message and prints the next active message. |
echo string | Echo the given string. Similar to the shell echo command. |
edit [message_list] | Invokes the editor specified by EDITOR and loads message_list into the editor. When you exit, any changes made are saved back into message_list. |
exit
ex x |
Exits mail without updating your system mailbox. |
file
[file]
fi [file] folder [file] fo [file] |
Selects a mail file or folder. If you do not specify a file, this command prints your current path and file name and the number of messages in your current file. If you specify a file or folder, this command displays any changes you have made to your current file and switches to the specified file for reading. |
folders | Lists the names of the folders in your folder directory. |
followup message | Responds to a message and record the response in a file whose name is derived from the author of the message. This command overrides the record option if set. |
Followup [message_list] | Responds to the first message in message_list and sends the message to the author of each message in message_list. The subject line is taken from the first message and the response is recorded in a file whose name is derived from the author of the first message. |
from
[login]
f [login] |
Prints the active message header. If you specify a login name, this command prints all the active messages from the specified name. |
headers
[n]
h [n] |
Lists active message headers, using the value of the screen variable as the number of headers to display. See Appendix D for a description of the screen variable. If you have more than one screenful of messages, you can move forward or backward one screenful with the z command. If you specify a message number, the headers command displays the screenful that includes the specified message. |
help | Displays help information. |
hold
[message_list]
ho [message_list] preserve [message_list] pre [message_list] |
Holds, or preserves, the current message or the specified specified messages in your system mailbox instead of moving them to your mbox file. |
if condition
else endif |
Construction for conditional execution of mailx subcommands. Subcommands following if are executed if condition is True. Subcommands following else are executed if condition is not True. An else is not required but the endif is required. The condition can be send for sending mail, or receive for receiving mail. |
ignore [field...] | Sets mailx to display messages without the specified fields of the header when you use the print or type command. Note that this command is different from the ignore variable described in Appendix D. If you enter the ignore command with no arguments, the current list of ignored fields is displayed. |
list | Displays a list of valid mailx subcommands. |
local | List other names for the local host. |
mail
user_name
m user_name |
Sends a message to the specified user. |
mbox [message_list] | Marks the current message or the specified messages to be moved to your mbox file. This is helpful if you have set the hold variable in your .mailrc file. |
more [message_list] | Displays the messages in message_list using the defined pager program in PAGER. Identical to the page subcommand. |
More [message_list] | Similar to the more subcommand, but also displays the ignored header fields. See more and ignore subcommands. |
new [message_list] | Marks each message in the message_list as not having been read. Identical to New, unread, and Unread subcommands. |
New [message_list] | Marks each message in the message_list as not having been read. Identical to new, unread, and Unread subcommands. |
page [message_list] | Displays the messages in message_list using the defined pager program in PAGER. Identical to the more subcommand. |
Page [message_list] | Similar to page but also displays the ignored header fields. Identical to the More subcommand. |
Command | Description |
pipe
[message_list]
[shell_command]
| [message_list] [shell_command] |
Pipes the message_list through the shell_command. The message is treated as being read. If no arguments are given, the current message is piped through the command given in cmd. If the page option is set, a formfeed is inserted after each message. |
next
n + [Return] |
Displays the next message. |
Print
[message]
P [message] Type [message] T [message] |
Displays the current message or the specified message, including any header fields specified by the ignore command. |
print
[message]
p [message] type [message] t [message] |
Displays the current message or the specified message without any header fields specified by the ignore command. |
quit
q |
Leaves the mailx program and updates your system mailbox. If you do not have the hold variable set, all messages that you have not deleted, saved, or preserved are moved to your mbox file. If you do have hold set, all these messages will be left in your system mailbox and marked as having been read. |
Reply
R Respond |
Replies to a message. If the original message was addressed to a group of people, replies sent with the Reply command are sent only to the originator of the message. |
reply
r respond |
Replies to a message. If the original message was addressed to a group of people, replies sent with the reply and respond commands are sent to everyone who received the original message. |
retain [field_list] | Adds the header fields in field_list to the list of headers to be retained when displaying message with the print or type subcommands. Use type and print to view messages in their entirety, including fields that are not retained. If retain is executed with no arguments, it lists the current set of retained fields. |
save
[message_list]
file
s [message_list] file |
Saves the current message or the specified messages in the file. Note that the messages are added to the specified file so that you will not delete the contents of the file. |
Save [message_list] | Saves the specified messages in a file whose name is derived from the author of the first messages. The name of the file is assumed to be the author's name with all network addressing stripped off. |
set
[variable]
se [variable] |
If entered with no variables, the set command displays all the options you have set. If you specify a variable, the option will be set. (Appendix E lists the available variables.) |
shell
sh |
Invokes the shell interactively. |
source
file
so file |
Reads mail commands from a file (usually .mailrc). |
size [message_list] | Displays the size in lines and characters of the messages in message_list. |
top
[message_list]
to [message_list] |
Displays the first five lines in the current message or each of the specified messages. |
touch [message_list] | Marks the messages in message_list to be moved from your system mailbox to your personal mbox when you quit the mailx program even though you have not read the listed messages. The messages appear in your mbox as unread messages. When you use touch, the last message in message_list becomes the current message. |
unalias alias_list | Deletes the specified alias names. |
undelete
message_list
u message_list |
Undeletes the specified messages. |
unread [message_list] | Marks each message in message_list as not having been read. Identical to the new, New, and Unread subcommands. |
Unread [message_list] | Marks each message in message_list as not having been read. Identical to the new, New, and unread subcommands. |
unset | Unsets (turns off) options. For example, if your .mailrc file includes a set hold command, you can use the unset command to disable the hold variable for the current mailx session. |
version | Displays the version banner for the mailx command. |
visual | Invokes the editor specified by the VISUAL mail variable to edit the current message. |
write
[message_list]
file
w [message_list] file |
Saves the current message or the specified messages in the named file. This is similar to the save command, except that write saves only the body of each message; the headers are deleted. |
z[+]
z- |
Moves forward or backward one screenful of messages. You can specify the number of messages in a screenful with the screen variable. (See Appendix D.) To move forward one full screen, enter z or z+; to move backward, enter z-. |