nmh-workers
[Top] [All Lists]

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

2013-04-28 13:30:23
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.

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>