Skip to content

Instantly share code, notes, and snippets.

@peterdalle
Created January 5, 2020 16:50
Show Gist options
  • Save peterdalle/8c9b511174a36ccc61383efdb9bc7466 to your computer and use it in GitHub Desktop.
Save peterdalle/8c9b511174a36ccc61383efdb9bc7466 to your computer and use it in GitHub Desktop.
Count number of lines of code within Git project with specified file extensions
git ls-files | grep -P ".*(js|css|html|aspx|ascx|vb)" | xargs cat | wc -l
@peterdalle
Copy link
Author

Bash only, no git:

find . -name "*.cs" | xargs cat | wc -l

Windows CMD equivalent in two steps. First, combine all files into one. Then count the number of lines in file:

for /R %f in (*.cs) do type "%f" >> test.txt
type test.txt | find /c /v ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment