[Fwd: Re: Send to a Listing]

Cameron Simpson cs at cskk.id.au
Sun Apr 14 21:19:14 UTC 2019

On 14Apr2019 20:06, felixs <besteck455 at gmail.com> wrote:
>fiddling with sed in the mutt mailing bash script

Nothing you're doing requires bash. Just use /bin/sh - "the shell" - it 
is portable; it _is_ bash on many linux systems (though by no means 
all), and it is _always_ present on any POSIX system. You're writing 
Bourne shell scripts, not GNU's particular dialect.

>I am writing I do not find
>a way to make sed read all files of a directory from standard in?
>I redirected standard input to a file and try to 'point' sed to all the
>files of the directory which is the spoolfile (maildir), like so:
>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,
>sed -ne '/^From: $EMAIL_ADDRESS/p ; /Subject: $SUBJECT/p' \
>< path/to/spoolfile/*    # error: ambiguous redirection
>< path/to/spoolfile/'1'*  #given that all msg files start with '1'
>or variations of that,
>it always fails with the above error messages.

Think about it. You're invoking sed _once_. Its input can come from only 
one file.

So invoke sed many times:

  for spoolfile in path/to/spooldir/*
    sed ..... < "$spoolfile"

>I searched in the documentation of sed (info sed)

The documentation should be in "man sed". But the GNU folks like to 
reader than fairly useless and shove the useful stuff sideways.

Regardless, redirection is part of the shell, and not part of sed, so 
what you want won't be there (unless there's some example that just 
happens to match what you're trying to do).

Have a read of "man sh". Everything is in there, in one place.

Cameron Simpson <cs at cskk.id.au>

More information about the Mutt-users mailing list