Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!novavax!hcx1!brad From: brad@SSD.CSD.HARRIS.COM (Brad Appleton) Newsgroups: comp.unix.questions Subject: Re: Piping stderr in Korn and/or Bourne Summary: Thank you Message-ID: <3660@hcx1.SSD.CSD.HARRIS.COM> Date: 8 Apr 90 16:58:37 GMT References: <3620@hcx1.SSD.CSD.HARRIS.COM> <9000029@m.cs.uiuc.edu> Sender: news@hcx1.SSD.CSD.HARRIS.COM Organization: Harris Computer Systems, Fort Lauderdale, FL Lines: 38 Thank you to all who replied to my Korn-shell question on piping stderr but leaving stdout alone! Below is a summary of my e-mail replies (you all saw the ones that were posted): Contents of file "tst": #!/bin/ksh print "this is stdout" print -u2 "this is stderr" Solutions: Michael T. Sullivan, Alan M. Carrol, and Andy Behrens all suggested: $ tst 2>&1 >/dev/tty | sed 's/std/STD/' This actually didnt work for me (probably to a slight system diff) I got "ksh: cannot create device". A minor variation fixed this up: $ tst 2>&1 >`tty` | sed 's/std/STD/' this is stdout this is STDerr Alan M. Carrol also suggested: $ tst 3>&2 2>&1 >&3 | sed 's/std/STD/' this is stdout this is STDerr (The old swap method) Works like a charm, also has the added benefit that it truly does leave stdout in the same place it was (tty or not). I hereby declare it the winner (IMHO of course ;-) Thank you all once again! -=-=-=-=-=-=-=-=-=-=-= "And miles to go before I sleep." =-=-=-=-=-=-=-=-=-=-=- Brad Appleton Harris Computer Systems brad@ssd.csd.harris.com (305) 973-5007 Fort Lauderdale, FL USA {uunet,novavax}!hcx1!brad -=-=-=-=-=-=-=-=-=-= Disclaimer: I said it, not my company! -=-=-=-=-=-=-=-=-=-