Advanced shell scripting question :-)

Marc Evans Marc at SoftwareHackery.Com
Wed Sep 4 19:15:30 EDT 2002


How about something like this:

	p 3>ERR 2>&3 2>&1 | tee OUTERR

Looking at the output of lsof, I think that this is doing the right thing:

cat        4157     marc    1w  FIFO    0,0           1092582 pipe
cat        4157     marc    2w  FIFO    0,0           1092582 pipe
cat        4157     marc    3w   REG    3,6       0        18 /tmp/ERR

- Marc

On Wed, 4 Sep 2002, Steven W. Orr wrote:

> I have a program (which we shall call p) which produces text to both
> stdout and stderr.
>
> I want the following three things to happen when I run p:
>
> 1. I want both stdout and stderr to go to the screen
>
> 2. I want stdout and stderr combined in a file
>
> 3. I want an error log file to only contain stderr.
>
> p 2>&1 | tee outnerr # Solves 1 and 2
>
> p 2> errlog	# Solves 3 but breaks 1 and 2
>
> p 2> errlog | tee out # Solves 3 but also breaks 1 and 2.
>
> Any takers?
>
> --
> -Time flies like the wind. Fruit flies like a banana. Stranger things have -
> -happened but none stranger than this. Does your driver's license say Organ
> -Donor?Black holes are where God divided by zero. Listen to me! We are all-
> -individuals! What if this weren't a hypothetical question? steveo at syslang.net
>
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
>




More information about the gnhlug-discuss mailing list