tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Logging ALL Keystrokes

nested expr commands ▻

Processing non-empty stdout/stderr

In article <7svmgk$t9e$1@nnrp1.deja.com>,
Alexander Sclearuc  <asclearuc@netinfo-moldova.com> wrote:
>It can be done redirecting these streams to temporary files, and than
>processing this files.

Yup.

>But could it be done using only features of the standard shell (standard
>Bourne shell). I would like to see smth like that:
>utility | ( if_stdout_non_empty process_stdout; if_stderr_non_empty
>process_stderr )

In the Bourne shell, I think using a temporary file is going to be
the easiest solution.

Here's an rc solution.

    ; { ls . /foo |sed 's/^/stdout: /' } |[2] sed 's/^/stderr: /'
    stdout: bin
    stdout: boddle
    stdout: data
    stdout: master
    stdout: stamp
    stdout: tmp
    stderr: /foo: No such file or directory

Tim.
--
Tim Goodwin   | "[ `static' ] is so overloaded in the C/C++ world that
Leicester, UK | I try to avoid it whenever I can't." -- Larry Wall

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell
Subject: Re: Processing non-empty stdout/stderr
Date: 1 Oct 1999 15:26:00 +0100
Organization: University of Leicester, UK
Message-ID: <7t2gae$bbu$1@ltpcg.star.le.ac.uk>
References: <7svmgk$t9e$1@nnrp1.deja.com>

△ comp.unix.shell △

◅ Logging ALL Keystrokes

nested expr commands ▻