Re: [linux-audio-user] A dumb Unix question about console output

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-user] A dumb Unix question about console output
From: toby_AT_tobiah.org
Date: Sun Jul 13 2003 - 05:13:24 EEST


> The part that is not fine, is that the output is not labeled with the
> application that it came from.
>
> For example, I seem to remember that if in the past, if you ran grep, for
> example, anything that grep sent to its console would be prefixed by "grep:"

Ewww... that would be terrible if I wanted to capture the output of a program
for later processing :)

No, you're thinking of stderr output, which by convention is
often prefixed with '$0:'. I mean, how would you like it if
you typed 'ls', only to get back:

ls: slow.wav
ls: slow.wav2
ls: smc_router_firmware
ls: sober
ls: sound
ls: soundon.log
ls: spell
ls: spell.bak
ls: src

etc... No, that's too Microshaft. Here is a possible solution:

Create an executable shell script in your path that looks like this:

#***** SCRIPT *****
function showme(){
         while read foo
                 do echo $1: $foo
         done
}

$@ | showme $1
#***** /SCRIPT *****

I called mine, "identify".

Now, let's test it with grep:

sinewave:toby:toby> identify grep foo *
grep: Binary file DSC00326.TIF matches
grep: Binary file QtC-0.0.2.lsm matches
grep: adf: afsdadsfadfasdfasdfasdfasdfasdfasdf toby adfadfadf foo
grep: adf: print('myfoot', 'myfoot');
grep: adf: print('yourfoot', 'yourfoot');
grep: doit: while read foo
grep: doit: do echo $1: $foo

So, now stdout and stderr get prefixed with the name
of the program. Easy, yes?

Tobiah


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Sun Jul 13 2003 - 05:20:29 EEST