#!/bin/sh # create 1001 C files, compile and runs them # file f$i.c contains a defintion of function f$i which returns $i # for example file42.c will contain a function f42 that returns 42 # # main.c contains code to call all 1000 functions # and print the sum of their return values # add the initial lines to main.c # note the use of quotes on eof to disable variable interpolation # in the here document cat >main.c <<'eof' #include int main(void) { int v = 0 ; eof i=0 while test $i -lt 1000 do # add a line to main.c to call the function f$i cat >>main.c <file$i.c <>main.c <<'eof' printf("%d\n", v); return 0; } eof # compile and run the 1001 C files time clang main.c file*.c ./a.out