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
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: 14156
    
  19

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Command to count the lines of code