Recent changes Random page
GAMING
Lifestyle
 
Recipes
Vintage Patterns
Genealogy
Pet Diabetes
Cocktails
How-To
See more...

Howto count the total number of lines in multiple files using a bash script

From Wikihowto

Jump to: navigation, search




You can use find and awk to counting the total number of lines in multiple files

[edit] Solution

Using the usual GNU tools, you can write the following script (replace "*.java" with your language file type):

find . -name "*.java" -exec wc -l '{}' \; | awk '{ sum += $1 } END { print sum }'
You can put this command in a bash script or create and alias


From HowTo Wiki, a Wikia wiki.
Rate this article:
Share this article: