UNIX-programming-io
You can do something like that in some shell - 'ls list.txt' and the output of ls command will be in that list.txt file.
Unbuffered I/O is provided by the functions open, read, write, lseek, and close. These functions all work with file descriptors.

#include <apue.h>
#include <stdlib.h>
int main(void){
int c;
while((getc(stdin)) != EOF)
if (putc(c, stdout) == EOF)
err_sys("read error");
if (ferror(stdin))
err_sys("input error");
exit(0);
}

