CSC 357 Lab 7
Getting Started with I/O redirection and
pipes
where IN_FILE, OUT_FILE1, and OUT_FILE2 are arbitrary file names. The point of these shell commands is to run the nwc and sgrep programs, and compare the results of sgrep with UNIX grep.nwc < IN_FILE | sgrep "out of" > OUT_FILE1 nwc < IN_FILE | grep "out of" > OUT_FILE2 diff OUT_FILE1 OUT_FILE2
The name of the C program you are writing is "lab7.c". It takes three command-line arguments for the three files used above, and performs the actions of the shell commands. For example, running
produces the same results as the shell commandslab7 lab7.c out1 out2
nwc < lab7.c | sgrep "out of" > out1 nwc < lab7.c | grep "out of" > out2 diff out1 out2
Performing the same actions as the shell commands means the following for the lab7 program:
The program must run under the following constraints:
When lab7 runs, you can assume the executables sgrep and nwc are in the same working directory where lab7 is running. For this purpose, you can copy the executables from the following two locations on hornet:
357/solutions/programs/1/sgrep 357/solutions/programs/2/nwc
The program lab7.c.
33 1/3 points for each of the three shell commands
Collaboration with a lab partner IS allowed, but each partner must turn a copy
of the work.
Submit the program via handin.