From owner-freebsd-questions Tue May 27 03:13:39 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id DAA06469 for questions-outgoing; Tue, 27 May 1997 03:13:39 -0700 (PDT) Received: from mail.EUnet.hu (www.eunet.hu [193.225.28.100]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id DAA06464 for ; Tue, 27 May 1997 03:13:36 -0700 (PDT) Received: by mail.EUnet.hu, id MAA14130; Tue, 27 May 1997 12:12:54 +0200 Received: (from zgabor@localhost) by CoDe.hu (8.7.5/8.7.3) id LAA00404; Tue, 27 May 1997 11:09:21 +0200 (MET DST) From: Zahemszky Gabor Message-Id: <199705270909.LAA00404@CoDe.hu> Subject: Re: What command line to redirect 'make world' warnings ? To: freebsd-questions@freebsd.org (FreeBSD questions) Date: Tue, 27 May 1997 11:09:20 +0200 (MET DST) Cc: ATuretta@stylo.it, un_x@anchorage.net In-Reply-To: <31EBCC36B676D01197E400801E032495021F4A@STYLOSERVER> from Angelo Turetta at "May 26, 97 09:36:00 pm" X-Mailer: ELM [version 2.4ME+ PL11 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > I've run: > > make world 2>&1 > /proxy/world3 > > and I would expect both stdout and stderr to go to file /proxy/world3. > Instead, warnings & errors continue to be directed to my tty. > > What should be the right command line ? (I'm using bash) 1) As somebody else said it, the correct form is: make world > /proxy/world3 2>&1 because redirection occures (most of the times) from left to right. So, in your version: stdout goes to tty stderr goes to tty redirection 2>&1 stderr goes to the same place as stdout, which is (of course) tty redirection > file stdout goes to file With the correct version: redirection > file stdout goes to file redirection 2>&1 stderr goes to the same place, as stdout, which is (now) file This type of redirection is working on all of the Bourne-shell-like shells (sh/ksh/pdksh/bash/zsh) 2) RTMF! from bash manual: --- Note that the order of redirections is significant. For example, the command ls > dirlist 2>&1 directs both standard output and standard error to the file dirlist, while the command ls 2>&1 > dirlist directs only the standard output to file dirlist, because the standard error was duplicated as standard output before the standard output was redirected to dirlist. .... Redirecting Standard Output and Standard Error Bash allows both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to the file whose name is the expansion of word with this construct. There are two formats for redirecting standard output and standard error: &>word and >&word Of the two forms, the first is preferred. This is seman- tically equivalent to >word 2>&1 This type of redirection is working only in bash (and not in any other sh-like shells - as I know -, but it works with csh, and other csh-like versions - tcsh, itcsh (I think, I've newer used itcsh)). 3) If you like, you can use your method, but with some minor corrections: ( make world 2>&1 >> /proxy/world3 ) > /proxy/world3 or { make world 2>&1 >> /proxy/world3 ; } > /proxy/world3 Of course, without the parentheses, it doesn't work (well, it shouldn't), and you have to use append ( >> ) inside. Well, why? It's your exercise. Bye, Gabor -- #!/bin/ksh Z='21N16I25C25E30, 40M30E33E25T15U!' ;IFS=' ABCDEFGHIJKLMNOPQRSTUVWXYZ ';set $Z;for i { [[ $i = ? ]]&&print $i&&break;[[ $i = ??? ]]&&j=$i&&i=${i%?};typeset -i40 i=8#$i;print -n ${i#???};[[ "$j" = ??? ]]&&print -n "${j#??} "&&j=;typeset +i i;};IFS=' 0123456789 ';set $Z;X=;for i { [[ $i = , ]]&&i=2;[[ $i = ?? ]]||typeset -l i;X="$X $i";typeset +l i;};print "$X"