Output redirection

Abhay B. Joshi joshi at motcid.UUCP
Fri Oct 19 07:44:03 AEST 1990


Hello Netters,

Following is a small C program.
-----------begin-------
#include <stdio.h>

main()
{
	fprintf(stdout,"Some People\n") ;
	fprintf(stderr,"Are In\n") ;
	fprintf(stdout,"Very \n") ;
	fprintf(stderr,"Deep\n") ;
	fprintf(stdout,"Trouble\n") ;
}
-----------end---------

Try to compile and execute it in the following ways:
	% a.out		# prints "Some People Are In Very Deep Trouble"
	% a.out >tmp 2>&1
	% cat tmp	# prints "Are In Deep Some People Very Trouble"

Sorry, I have removed the newlines between the words. But the sequence is
of importance.

Is there a way to keep the sequence the same, while using o/p redirection ?
Thanks.

Abhay Joshi
uunet!motcid!joshi



More information about the Comp.unix.shell mailing list