This supposed program will write to file descriptor number you specified.
consider the following hello world program:
#include <stdio.h>
main()
{
ssize_t i = 0 ;
printf ("hello world\n") ;
i = write( 5 , "Bonjour Monde\n", 14 ) ;
printf ("%d octet dans 5\n", (int) i) ;
}
compile it
me@mybox:~/tmp7$ make hw
cc hw.c -o hw
now a simple run
me@mybox:~/tmp7$ ./hw
hello world
-1 octet dans 5
no file for 5, so no byte wrote.
next try:
me@mybox:~/tmp7$ ./hw 5> u
hello world
14 octet dans 5
me@mybox:~/tmp7$ cat u
Bonjour Monde
I manage to get an output while specifying a file and a file descriptor (e.g. 5>u
).
In practice, unless you have wrote such funny program as above, you are unlikely to collect data using 5>foo
.
in shell script, construct using <( ) are more usefull:
diff <( cmd -par 1 ) <(cmd -par 2)