A
A
Alexey2015-05-28 16:49:52
bash
Alexey, 2015-05-28 16:49:52

How to recursively traverse a directory tree and count the number of lines in all .py files?

Good afternoon. It is necessary to somehow calculate the number of lines of code in the project, I can’t figure out how to do it. Trying to build a command for bash from ls, find, wc, grep but nothing comes up. For example, there is a directory structure like this:

.
├── 1.py
├── 2.py
└── folder
    └── 3.py

Tell me how to calculate the total number of lines in .py files?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2015-05-28
@MAKAPOH

find -name '*.py' | xargs wc -l
The last line will be the total number of lines.
You can do this:
find -name '*.py' | xargs cat | wc -l

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question