[Fwd: Re: Send to a Listing]

Nathan Stratton Treadway muttlists at nathanst.com
Sun Apr 14 21:38:31 UTC 2019


On Sun, Apr 14, 2019 at 20:06:04 +0200, felixs wrote:
> sed -ne '/^From: $EMAIL_ADDRESS/p ; /Subject: $SUBJECT/p' \
> < /path/to/spoolfile
> 
> If I specify a message file on the command line it works. If I try to
> make sed take its input from ALL the files in the directory using the
> above syntax it does not. I use, for instance,

If you don't enter any file names on the sed command line it reads from
stdin (and thus works with your "< /path/to/spoolfile" redirect).

However, sed can instead accept a list of files on the command line and
it will then read from each in turn, so instead of having the shell
redirect stdin, just put the wildcard path as the trailing argument on
the command line and let the shell expand the wildcard into the list of
individual files:
  sed -ne '/^From: $EMAIL_ADDRESS/p ; /Subject: $SUBJECT/p' path/to/spoolfile/*

(The applicable paragraph from the [GNU] sed man page is:
       If no -e, --expression, -f, or --file option is given, then  the first
       non-option  argument  is  taken  as  the  sed script to interpret.  All
       remaining arguments are names of input files; if  no  input files  are
       specified, then the standard input is read.
)

						Nathan


More information about the Mutt-users mailing list