• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Command to count the lines of code

 
divya chamarti
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wc (word count) counts characters, words and lines, so "wc -l" can count the number of lines.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeff Rummings
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can download SLOC count. It supports different languages, easy to use and does everything for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic