Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.6.2.13 $; site uiucdcs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!ihnp4!inuxc!pur-ee!uiucdcs!liberte From: liberte@uiucdcs.UUCP Newsgroups: net.unix Subject: Awk error redirection - (nf) Message-ID: <39300009@uiucdcs.UUCP> Date: Thu, 3-May-84 21:27:00 EDT Article-I.D.: uiucdcs.39300009 Posted: Thu May 3 21:27:00 1984 Date-Received: Sat, 5-May-84 01:32:37 EDT Lines: 40 Nf-ID: #N:uiucdcs:39300009:000:1475 Nf-From: uiucdcs!liberte May 3 20:27:00 1984 #N:uiucdcs:39300009:000:1475 uiucdcs!liberte May 3 20:27:00 1984 I received the following (edited) letter which I couldnt respond to via mail. I thought the solution to Don's awk problem was general enough to post. ---------------------- From tekig1!dont%tektronix.csnet@csnet-relay.csnet Wed May 2 18:45:33 1984 Via: Rand; 2 May 84 18:45-CDT How the #$%&^@!!%$ do you get AWK to print something on the error output? Don Taylor tektronix!tekig1!dont ---------------------- Try something like this awk.prog: {print "Error output: " $0 | "tee >&2"} {print "Standard out: " $0 } In csh: awk -f awk.prog # causes both to go to terminal. awk -f awk.prog >& awk.out # both go to awk.out awk -f awk.prog > awk.out # puts errors to terminal, standard output to awk.out >>>>> (awk -f awk.prog > awk.out) >& awk.error # puts standard output in awk.out and errors in awk.error In sh, replace '>& file' with '> file 2>&1' to get the same results. So there is a difference. I am not sure that '| "tee >&2"' is the best way to do it. This trick uses the bourne shell output redirection inside awk. It would be nice to have more general IO redirection within awk as long as they have gone to so much trouble to have any (> >> and |). Why dont they just document some of these handy things instead of making us figure it out individually like some adventure game? It is fun to discover tho... Daniel LaLiberte, U of Illinois, Urbana-Champaign, Computer Science {moderation in all things - including moderation}