Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in DevOps and Agile by (29.3k points)

How would I count the total number of lines present in all the files in a git repository?

git ls-files gives me a list of files tracked by git.

I'm looking for a command to cat all those files. Something like

git ls-files | [cat all these files] | wc -l

1 Answer

0 votes
by (50.2k points)

For this question, xargs will help you to count the number of lines in a git repository.

Let’s see how this works

git ls-files | xargs cat | wc -l

For more information you better use

git ls-files | xargs wc -l

 This will count the number of lines in a git repository.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...