In: Computer Science
C programming in Shell
Implement a MS-DOS style pipe command. Make sure it allows for command-line arguments to be passed to the programs. You only need to support one pipe command at a time. For example, when you type ls | wc the shell should
Here is the C code for you:
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#include <stdlib.h>
int main (void) {
   char command[20];
   printf("Enter your command: ");
   fgets(command, 80, stdin);   /* Read a
command as input from keyboard */
   system(command);       /*
Execute the command */
}
And the sample output screenshot is:

This code works for any shell commands you execute directly in terminal.