aspose file tools*
The moose likes Linux / UNIX and the fly likes Command to count the lines of code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Command to count the lines of code" Watch "Command to count the lines of code" New topic
Author

Command to count the lines of code

divya chamarti
Ranch Hand

Joined: Jul 28, 2006
Posts: 56
If you have to count the lines of code in all Java programs in the directories under your home directory how would you do that?
Please help in finding out the solution
Thanks in advance
Divya
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

wc (word count) counts characters, words and lines, so "wc -l" can count the number of lines.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

And with a command like "find" you can find files, for example all *.java files in a certain directory:

find /home/divya -name *.java

See the man pages for these commands:

man find
man wc


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jeff Rummings
Ranch Hand

Joined: Dec 20, 2007
Posts: 42
Or you can download SLOC count. It supports different languages, easy to use and does everything for you.
 
jQuery in Action, 2nd edition
 
subject: Command to count the lines of code
 
Similar Threads
Why does it not compile ?
calculating LLOC
How to get // and /* symbols out of tokens?
Understanding Nested For Loops
Head First Object Exercise Chapter Two