======================================================================= U N I X T U T O R I A L by Glenn Chappell ======================================================================= Unix Tutorial (September 1994 version) by Glenn Chappell (Feel free to distribute this document however you want.) Chapter V. Mail ----- Part 2 - "&" prompt commands ----- Covered: Mail commands: ? d f m p q r R s u w x ! When mail starts up, it will give a brief summary of the first 20 messages you have waiting, and then give you the "&" prompt. At this point you can type one of many mail commands. Or you can just press . Pressing return will print the next message, piping its output through "more" so that you see the message page by page. Typing a number and pressing return will print the message with that number. A very important command is "?". This lists the principal commands available at the "&" prompt (it does not, however, list all the commands available): & ? cd [directory] chdir to directory or home if none given d [message list] delete messages e [message list] edit messages f [message list] show from lines of messages h print out active message headers m [user list] mail to specific users n goto and type next message p [message list] print messages pre [message list] make messages go back to system mailbox q quit, saving unresolved messages in mbox r [message list] reply to sender (only) of messages R [message list] reply to sender and all recipients of messages s [message list] file append messages to file t [message list] type messages (same as print) top [message list] show top lines of messages u [message list] undelete messages v [message list] edit messages with display editor w [message list] file append messages to file, without from line x quit, do not change system mailbox z [-] display next [previous] page of headers ! shell escape A [message list] consists of integers, ranges of same, or user names separated by spaces. If omitted, mail uses the current message. Probably the most useful commands on this list are d, f, m, p, q, r, R, s, u, x and !, and I will explain these now. With most of the commands, I have given a mnemonic, after it in parentheses. First of all, "m" is just an abbreviation for "mail". You can send a message to me using & m ggc@uiuc.edu "d" (delete), as the help listing indicates, deletes messages. It is followed by an optional "message list". A typical message list is "2", so & d 2 deletes message number 2. You may separate message numbers by spaces: & d 2 4 10 deletes messages 2, 4 and 10. A "range" is two numbers with a dash between them: & d 11-16 deletes messages 11 through 16. All these may be put together, separated by spaces: & d 8 2 4-6 20 10-15 will delete messages 2, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15 and 20. Messages are not renumbered until you quit mail. Along with "-" you may use "^" and "$" to represent the first and last undeleted messages, respectively. Thus, & d ^-5 deletes all messages up to and including #5, while & d 10-$ deletes message #10 and all following messages. By the way, "^", meaning "first" or "beginning", and "$", meaning "last" or "end" are a common feature of many Unix programs. Two other options are no numbers: & d deletes the current message (the one just printed out) and "*", which indicates all messages: & d * will delete all messages (as will "d ^-$"). The "d" command really does not delete messages immediately. Rather, it makes messages invisible and marks them for deletion. There are two ways to exit mail: "q" and "x". "q" deletes all marked messages, while "x" does not. Because of this, before you exit mail, you have the option to "undelete" messages. This is accomplished with the "u" command. For example, if message 5 has been "deleted", then before you leave mail, you can type "u 5" to undelete it. Then, even if you exit using "q", message #5 will not be removed. "f" (from) prints the "from lines" of the messages you specify, similar to what mail does when you first enter it. All the options available with "d" are also available with "f". So, for example, & f * gives a brief overview of all the messages you have available. One small problem with "f *" is that it sets the "current message" to the last undeleted message. Thus, after typing "f *", if you want to resume reading where you were before, you must type a message number. "p" (print) prints out messages. Thus, to print all messages, type & p * If you have just read a message and would like to reread it, simply type & p "q" (quit) and "x" (exit), as was noted earlier, exit mail, but with very different results. Normally, you will exit with "q". "q" removes all deleted messages, and, if you are reading your incoming mail, it moves all the messages you have read but not deleted to a file called "mbox" in your directory. "x", on the other hand, leaves the mail file alone. It unmarks all marked messages, deletes nothing, and, in general, leaves the file exactly as it was when you entered mail. Thus, "q" is the standard way to leave, while "x" is the safe way. "r" and "R" (reply) are used to reply to the current message (generally, the one you have just read). "r" sends a message to the sender of the current message, while "R" sends to the sender and all recipients. "s" (save) appends messages to a file. Say you have a text file called "temp": & s 1-3 temp appends messages 1, 2 and 3 to temp. "s" is one way of creating files of messages, accessible with "% mail -f filename". "s" puts messages in a text file, but it puts them there in what is known as "mailbox format". In other words, if a text file is *created* using "s", and everything that is subsequently placed into it is placed there with "s", then that file will be formatted properly for use with mail. Then, from the shell, % mail -f filename (with "filename" replaced by the appropriate filename) allows you to access these messages. Note: the "&" prompt "w" command also appends messages to a text file, but does not do so in mailbox format. "!" does what is known as a "shell escape". This is a very common feature of Unix programs that have their own prompt, and it usually involves typing "!". In mail, typing "!" followed by a shell command is just like typing that command in the shell. For example & !ls will list the contents of your current working directory. At the end, it will print "!" to indicate that the shell escape is over and you are back in mail. ------------------------------------------------------------------------