UNIX SHELL EXERCISES
Create a file named "rand.c" that contains the following program, and
compile it.
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i;
for (i = 0; i < 100; i++)
printf("%d\n", rand() % 1000);
return 0;
}
For exercises 1-7, describe what happens when you type the given commands.
1. phoenix.Princeton.EDU% more rand.c
2. phoenix.Princeton.EDU% a.out
3. phoenix.Princeton.EDU% mv a.out rand
phoenix.Princeton.EDU% rand
4. phoenix.Princeton.EDU% rand > data.txt
phoenix.Princeton.EDU% more data.txt
5. phoenix.Princeton.EDU% sort < data.txt
phoenix.Princeton.EDU% sort -n < data.txt
6. phoenix.Princeton.EDU% sort -n < data.txt > data-sorted.txt
phoenix.Princeton.EDU% more data-sorted.txt
7. phoenix.Princeton.EDU% rand | more
phoenix.Princeton.EDU% rand | sort -n | more