If there is a better or more correct way to do this, anyone feel free to correct me, as my grep-fu is muy pobre.
$ cat * | grep -c ' */'
6386
Doesn't that * in your regular expression mean "greedily match as many of the preceding SPACE character as possible including zero, followed by the /" ?
So, what you've done is counted all the slashes in the code. Let's imagine that there are not many divide /, and there are not that many pathname /, so you're double counting the comments and should at least divide your 6386 in half
you want
$ cat * | grep -c ' \*/'
the backslash is protected by the single quotes, so it will get passed to grep where it will mean "literally *" rather than the regular expression operator * (now I'm thinking my \ is going to get swallowed up by HN so I'd better double them? ed: nope, didn't have to double, but I did have to backslash escape the asterisk after literally)
So, what you've done is counted all the slashes in the code. Let's imagine that there are not many divide /, and there are not that many pathname /, so you're double counting the comments and should at least divide your 6386 in half
you want
the backslash is protected by the single quotes, so it will get passed to grep where it will mean "literally *" rather than the regular expression operator * (now I'm thinking my \ is going to get swallowed up by HN so I'd better double them? ed: nope, didn't have to double, but I did have to backslash escape the asterisk after literally)