Redirection quirks: 2>&1 >file -- vs. -- >file 2>&1

Douglas J. Wait doug at ides.UUCP
Mon Jan 6 23:50:11 AEST 1986


> Consider:
> 
>     $ command 2>&1 >file
>     $ command >file 2>&1
> 
> These are not equivalent using our 4.2bsd Bourne shell.  (The 2>&1 in the
> first line redirects unit 2 to the tty, not to the file.)
> Is this a feature or a bug?  Comments not worthy of world-wide
> net readership should be mailed to me, not posted, please.
> -- 
>         -IAN!  (Ian! D. Allen)      University of Waterloo

Have you read your documentation ? ....  Mine tells me that:

 "...  The shell evaluates redirections left-to-right.  For example:

    ... 1>xxx 2>&1

 first associates file descriptor 1 with file xxx.  It associates file
 descriptor 2 with the file associated with file descriptor 1 (i.e., xxx).
 If the order of redirections were reversed, file descriptor 2 would be
 assocated with the terminal ....

This is from SysVr2 sh(1).


-- 

			Doug Wait
			AT&T Information Systems
			850 Trafalgar Ct.
			Maitland, FL 32751
			(305)660-3471

			..!{akgua,ihnp4,abcom}!ides!doug

			"Is anyBODY OUT there..."



More information about the Comp.unix.wizards mailing list