Fast lines of code count command.

Ever wanted to quickly check how many lines of code have been written in your current working project? Here is a quick command I've been using!

Published 2022-06-07


Here is a really quick command I've been using to count the lines of code in my current project.

git ls-files | grep -Ev '<dirs_files_to_ignore>' | xargs wc -l | grep total | sed 's/[^0-9]*//g' | awk '{ print "\n" $1 " lines of code in this project"}'

Please note that <dirs_files_to_ignore> needs to have pipe seperated values for any directories or files you want to ignore from the count, for example:

git ls-files | grep -Ev 'node_modules|dist|.png|.jpg.|.jpeg|package.json|package-lock.json' | xargs wc -l | grep total | sed 's/[^0-9]*//g' | awk '{ print "\n" $1 " lines of code in this project"}'

Hope this helps!


AuthorChristopher Talke

TopicsGit, Command Line and Linux

Find an issue with this post? Think you could clarify, update or add something? All my posts are available to edit on Github!