How to count files & lines of code on the command line
At times it’s useful to know how many lines of code your software projects consist of, even if just for bragging rights about the scale of the work you’re doing.
To count the files and lines of code (text) in a directory from the command line, open a new Terminal window, switch to the directory that contains your source code, and enter the following command:
echo 'files: '; find . -type f | wc -l; echo 'lines: ';
grep -R '.' * | wc -l
After the command runs for a few seconds, you’ll see output similar to the following:
files:
301
lines:
37217