From owner-freebsd-hackers Wed Mar 22 10:17:09 1995 Return-Path: hackers-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id KAA11198 for hackers-outgoing; Wed, 22 Mar 1995 10:17:09 -0800 Received: from cs.weber.edu (cs.weber.edu [137.190.16.16]) by freefall.cdrom.com (8.6.10/8.6.6) with SMTP id KAA11192 for ; Wed, 22 Mar 1995 10:17:08 -0800 Received: by cs.weber.edu (4.1/SMI-4.1.1) id AA11113; Wed, 22 Mar 95 11:10:47 MST From: terry@cs.weber.edu (Terry Lambert) Message-Id: <9503221810.AA11113@cs.weber.edu> Subject: Re: Strange behaviour of sh To: wmbfmk@urc.tue.nl Date: Wed, 22 Mar 95 11:10:46 MST Cc: hackers@FreeBSD.org In-Reply-To: <199503221753.SAA05048@nietzsche> from "wmbfmk@urc.tue.nl" at Mar 22, 95 06:53:01 pm X-Mailer: ELM [version 2.4dev PL52] Sender: hackers-owner@FreeBSD.org Precedence: bulk > > Hi All, > > I need to call a program with the system call and have stdout and > stderr redirected to a file, however when I issue the following > command: > > cat foo0 >& foo1 > > sh responds with: > > Syntax error: bad fd number > > The above line is the correct syntax to redirect stdout and stderr to > a file or isn't it? No, it is not. Use: cat foo0 > foo1 2>&1 Instead. the '>&' construct in sh is [#]>&#, where # is a file descriptor number to redirect to and [#] is an option fd to redirect (default is 1, stdout). This should be in the syntax section of the sh man page. Terry Lambert terry@cs.weber.edu --- Any opinions in this posting are my own and not those of my present or previous employers.