Find and Specify with scan, pick, Ranges, Sequences

[previous] [next] [table of contents] [index]

MH gives you a lot of ways to find particular messages -- and to specify one or more messages without giving the message numbers. Here are a few examples.

If you type scan at a shell prompt, you'll get a list of all the messages in your folder. The list looks like the one you get with inc, but it shows all your messages:

% scan
   1  01/09 Joe Doe            Here's the first message you asked
   2 -01/09 Joe Doe            Another test<<Well, this is another
   3  01/09 To:Joe Doe         What's happening -- did you send the
   4+ 01/09 To:angelac         A long message<<AWK(1) USER COMMANDS AWK(1)
   5  01/09 To:Joe Doe         Thanks for helping!<<You said that
   6  01/09 Sample MH/MIME me  Sample MIME message for online MH book
The dash (-) next to message 2 means that you've replied to it with the repl -annotate command. The plus sign (+) next to message 4 means that it's the current message. If you sent a particular message, scan shows To:recipient as demonstrated in messages 3-5. (To make this work even better, read about Defining Alternate Mailboxes.)

If you have a lot of messages, you don't have to scan all of them. You can specify message numbers, ranges, and MH sequences. For example, to scan the range of messages number 2 through 5, inclusive, type:

% scan 2-5
To scan the current message and the last three messages, type:
% scan cur last:3
Many MH commands let you give more than one message number at a time. There are quite a few ways to do this. Here are some examples. Compare them to the explanations that follow:
% show 3 7 22
% show 3-7 22
% scan last:20
% scan first-cur
The first show command shows message numbers 3, 7, and 22. The second show command shows messages in the range 3 through 7 (like 3, 4, 5, 6, and 7, though not all of them have to exist) and also message 22. The first scan command scans the last 20 messages in the folder. The second scan command starts scanning at the first message in the folder (which isn't necessarily message 1) and continues through the current message. For more information, see your online mh-sequence(5) manual page.

(Of course, this is most useful when you have more than five messages in your folder.)

The MH pick command lets you search for messages by what's in a header field or body. If you wanted to find all messages which have the word "oyster" in the header or body:

% pick -search oyster
Messages 1 and 4 contain that word.

Of course, the message numbers usually aren't enough. You'll usually want to scan the messages or read them or something -- and retyping the message numbers is a pain, especially if there are a lot of them. MH has sequences, stored lists of message numbers with a name. MH commands that accept message numbers also accept sequences -- just type the sequence name. You can tell pick to store matching message numbers in a sequence, too. For instance, the next example shows how to pick all messages you sent to the user freddie and save the numbers in a sequence called picked. I use the stored sequence twice -- first, to scan the messages; then, to forward them:

% pick -to freddie -sequence picked
3 hits
% scan picked
   6  01/10 To:freddie         Plans for the new project, part 1
  12  01/10 To:freddie         Plans for the new project, part 2
  14  01/11 To:freddie         Oops -- read this<<Freddie, I mad
% forw picked
To: ehuser
Subject: Messages I sent to Fred F.
Time savers: You can abbreviate most MH switches; for example, you can type -seq instead of -sequence. Also, as with other MH commands, you can save typing by storing default switches like -sequence picked in your MH profile.

There's much more about pick in the Section Finding Messages with pick and the pick(1) manual page. (Here are the manual pages.) And, as with all MH commands, you can get a quick list of all pick switches by typing:

% pick -help

[Table of Contents] [Index] [Previous: Forwarding Messages: forw] [Next: Cleanup: rmm]

Revised by Jerry Peek. Last change $Date: 1999/10/10 05:14:05 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Jerry Peek <>