#include #include #include #include int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Wrong argument count!\n"); return 1; } int fd = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, 0644); if (fd == -1) { perror("Opening the file failed"); return 1; } close(1); dup(fd); close(fd); system("date '+%F %T'"); write(STDOUT_FILENO, "Hello", 5); printf(" world!\n"); return 0; }