I am trying to implement the commandin C.Code:sort myshell.c > 2
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; }