F    Using the mailx Commands

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.

Table F-1:  Commands for the mailx Program

Command Description

=

Echoes the number of the current message.

#

Lets the user 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. An error message is displayed if you attempt to move back more messages than are in the mailbox.

?
help

Displays help information.

alias
alias alias
alias alias name...
group
g

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.

alternate[alt_list]

Informs mailx that the addresses listed in alt_list refer to the user. If no alt_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 mailx environment.

copy  [msg_listfile
co [msg_listfile
c [msg_listfile

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  [msg_list]
C  [msg_list]

Saves the specified messages in a file whose name is derived from the author of the first message in the msg_list. This command will not mark the messages as being saved. Otherwise equivalent to the Save command.

delete [msg_list]
d [msg_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

Echoes the given string. Similar to the shell echo command.

edit [msg_list]
e [msg_list]

Invokes the editor specified by EDITOR and loads msg_list into the editor. When you exit, any changes made are saved back into msg_list.

exit
ex

Exits mailx without updating your system mailbox.

file [file]
fi [file]
folder [file]
fold [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
fo message

Responds to a message and records the response in a file whose name is derived from the author of the message. This command overrides the record option if set.

Followup [msg_list]
F [msg_list]

Responds to the first message in msg_list and sends the message to the author of each message in msg_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.

hold [msg_list]
ho [msg_list]
preserve [msg_list]
pre [msg_list]

Holds, or preserves, the current message or the specified messages in your system mailbox instead of moving them to your mbox file.

if condition
condition
else
e
endif
en

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. 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
l

Displays a list of valid mailx subcommands.

local

Lists other names for the local host.

mail user_name
user_name

Sends a message to the specified user.

mbox [msg_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 [msg_list]

Displays the messages in msg_list using the defined pager program in PAGER. Identical to the page subcommand.

More [msg_list]

Similar to the more subcommand, but also displays the ignored header fields. See more and ignore subcommands.

new [msg_list]
New [msg_list]

Marks each message in themsg_list as not having been read. Identical to the unread and Unread subcommands.

page [msg_list]

Displays the messages in msg_list using the defined pager program in PAGER. Identical to the more subcommand.

Page [msg_list]

Similar to page but also displays the ignored header fields. Identical to the More subcommand.

pipe [msg_list] [shell_cmd]
pi  [msg_list] [shell_cmd]
|  [msg_list] [shell_cmd]

Pipes the msg_list through the shell_cmd. 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. Use the exit subcommand to end the session without saving messages.

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 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 [msg_listfile
s [msg_listfile

Saves the current message or the specified messages in the file. The messages are added to the specified file so that you will not delete the contents of the file.

Save [msg_listfile
S [msg_listfile

Saves the specified messages in a file whose name is derived from the author of the first message. 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 D lists the available variables.)

shell
sh

Invokes the shell interactively.

source file
so file

Reads mail commands from a file (usually .mailrc).

size [msg_list]
si [msg_list]

Displays the size in lines and characters of the messages in msg_list.

top [msg_list]
to [msg_list]

Displays the first several lines in the current message or each of the specified messages. The number of lines displayed is specified by the toplines variable. The default is five.

touch [msg_list]

Marks the messages in msg_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 msg_list becomes the current message.

unalias alias_list

Deletes the specified alias names.

undelete msg_list
msg_list

Undeletes the specified messages.

unread [msg_list]
Unread [msg_list]
U [msg_list]

Marks each message in msg_list as not having been read. Identical to the new and New subcommands.

unset [variable]
uns [variable]

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
ve

Displays the version banner for the mailx command.

visual
v

Invokes the editor specified by the VISUAL mail variable to edit the current message.

write [msg_listfile
w [msg_listfile

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-.