count lines of code
How many lines of code a project has, in total and by language.
Steps
-
cloc .lines of code, comments and blanks, by language (cloc)
-
tokeithe same, faster (tokei)
-
git ls-files | xargs wc -l | tail -1the lines of every file git tracks
-
find . -name '*.py' -print0 | xargs -0 wc -l | tail -1the lines of every .py file
Commands used
cloctokeiwcgit
Each has a page in lore: lore cloc opens it.
Related recipes
- fix windows line endings"bad interpreter: ^M" and odd characters: the file has Windows line endings (CRLF). Find them and change them to Unix ones (LF).
- pretty-print jsonShow JSON indented and coloured, pick values out of it, from a file or a web request.
- read a file line by lineGo through a file's lines in a script, also split into fields, without losing spaces or backslashes.
- add up numbers in a fileSum a column of numbers, from a file or a command's output.