nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] Inability to cat a Message Part.


From: Ralph Corderoy
Subject: Re: [Nmh-workers] Inability to cat a Message Part.
Date: Sun, 28 Apr 2013 19:30:20 +0100

Hi David,

> >     $ ls -d / /known /unknown 2> >(sed '\#/known:#d' >&2) | sed 's/^/1:/'
> >     ls: cannot access /unknown: No such file or directory
> >     1:/
> >     $
>
> Thanks, but I used grep.  I don't use sed unless I really have to :-)

It applies to grep too.  We want ls to produce stdout and stderr, just
like normal, but we want to filter out one expected line from stderr.
Without the correction, grep takes its stdin AKA ls's stderr and puts
the results to its stdout.  By default, that will be ls's stdout so
we'll have merged ls's stdout and stderr.  This can be seen by all
stdout lines have a `1:' prefix, 1 being stdout's file descriptor.

    $ ls -d / /known /unknown 2> >(grep -v /known:) | sed 's/^/1:/'
    1:/
    1:ls: cannot access /unknown: No such file or directory
    $

By setting grep up to have its stdout be its stderr, which is ls's
stderr, we preserve the distinction between ls's two output streams.

    $ ls -d / /known /unknown 2> >(grep -v /known: >&2) | sed 's/^/1:/'
    ls: cannot access /unknown: No such file or directory
    1:/
    $

Cheers, Ralph.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]