I am trying to implement the command
Code:
sort myshell.c  > 2
in C.

But I am having difficulties understanding how to use pipelines to do so.

Code:
int main(){
  char *args[] = {"sort", "myshell.c", ">", "2"};
  int size = sizeof(args)/sizeof(*args);
  int rw[2]//pipes
  int i;
  pipe(rw);
  FILE* file;


  for(i = 0; i < size; i++){
        if(!strcomp(args[i], ">")){
                file = args[i+1];//getting the file name (in this case 2)
        }
  }


  if((pid = fork()) == 0){//child


        int fd = open(file, O_CREAT | O_RDWR);


  }else{//parent


  }




return 0;
}