C (clang), 209 bytes
char i,j,*l;regex_t r;f(n,s,t)char*n;{if(fnmatch("*.sh",n,0))return 0;FILE*f=fopen(n,"r");regcomp(&r,"^\\s*(#|$)",1);while((i=getline(&l,&i,f))^-1)!regexec(&r,l,0,0,0)?j++:0;}main(){ftw(D,f,1);printf("%d",j);}
char i,j,*l;regex_t r;f(n,s,t)char*n;{if(fnmatch("*.sh",n,0))return 0;FILE*f=fopen(n,"r");regcomp(&r,"^\\s*(#|$)",1);while((i=getline(&l,&i,f))^-1)!regexec(&r,l,0,0,0)?j++:0;}main(){ftw(D,f,1);printf("%d",j);}