Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Mar 95 11:10:46 MST
From:      terry@cs.weber.edu (Terry Lambert)
To:        wmbfmk@urc.tue.nl
Cc:        hackers@FreeBSD.org
Subject:   Re: Strange behaviour of sh
Message-ID:  <9503221810.AA11113@cs.weber.edu>
In-Reply-To: <199503221753.SAA05048@nietzsche> from "wmbfmk@urc.tue.nl" at Mar 22, 95 06:53:01 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9503221810.AA11113>