3

How do I calculate the number of lines written in a project containing multiple sub dirs in a python project. for example a dir structure is like

A  
 \ <*some files here*>\  
  B  
   \ <*some files here*>\ ... and so on...
1
  • 3
    cloc Commented Sep 29, 2011 at 0:43

1 Answer 1

14

You could use the find utility in linux.

On the command prompt:

$ find <project_directory_path> -name '*.py' | xargs wc -l

This will give you the count of all files ending with .py in the project_directory and finally the total. (I am assuming you just want the count of .py files)

If you just want the total and nothing else, you could use:

$ find <project_directory_path> -name '*.py' | xargs wc -l | tail -1
Sign up to request clarification or add additional context in comments.

2 Comments

That will not give you the total but just for individual files.
You're right, slipped my mind that -exec works on the individual file and will not provide a total (unless we use some nasty awk).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.