Count Source Lines of Code - sloc.sh

Simple Script to Count Code

This handy BASH script uses ack, awk & perl to count source lines of code.

Download the sloc.sh script.

Read about SLOC (or here) & Program Language Popularity.

Other Tools: sloccount, github.com/manveru/SLOC, github.com/flosse/sloc.

Count your Whole Project

./sloc.sh
Files (batch): 2
    Code: 46
    Hash: 0
    Line: 0
    Wide: 0
    Void: 6
    Full: 52
Files (cfmx): 24
    Code: 4002
    Hash: 3
    Line: 64
    Wide: 23
    Void: 387
    Full: 4479
Files (css): 37
    Code: 5793
    Hash: 286
    Line: 1
    Wide: 430
    Void: 765
    Full: 7275
Files (html): 71
    Code: 8943
    Hash: 0
    Line: 216
    Wide: 29
    Void: 931
    Full: 10119
Files (js): 206
    Code: 41079
    Hash: 0
    Line: 944
    Wide: 4678
    Void: 5985
    Full: 52686
Files (perl): 14
    Code: 1562
    Hash: 504
    Line: 0
    Wide: 0
    Void: 285
    Full: 2351
Files (php): 741
    Code: 88274
    Hash: 638
    Line: 3647
    Wide: 13333
    Void: 10685
    Full: 116577
Files (plone): 9
    Code: 712
    Hash: 102
    Line: 0
    Wide: 0
    Void: 162
    Full: 976
Files (python): 9
    Code: 712
    Hash: 102
    Line: 0
    Wide: 0
    Void: 162
    Full: 976
Files (shell): 1
    Code: 156
    Hash: 10
    Line: 0
    Wide: 0
    Void: 30
    Full: 196
Files (web): 1055
    Code: 144089
    Hash: 924
    Line: 4808
    Wide: 18470
    Void: 18366
    Full: 186657
Files (xml): 5
    Code: 416
    Hash: 0
    Line: 0
    Wide: 0
    Void: 2
    Full: 418
Total Files: 2174
    Code: 295784
    Comments: 2569 / 9680 / 36963 (#, //, /**/)
    Blank Lines: 37766
    Total Lines: 382762

Count Specific File Types

Using the types defined by ack. First one type, then two types

./sloc.sh -t=php
Files (php): 741
    Code: 88274
    Hash: 638
    Line: 3647
    Wide: 13333
    Void: 10685
    Full: 116577
./sloc.sh -t=php -t=js
Files (php): 741
    Code: 88274
    Hash: 638
    Line: 3647
    Wide: 13333
    Void: 10685
    Full: 116577
Files (js): 206
    Code: 41079
    Hash: 0
    Line: 944
    Wide: 4678
    Void: 5985
    Full: 52686
Total Files: 947
    Code: 129353
    Comments: 638 / 4591 / 18011 (#, //, /**/)
    Blank Lines: 16670
    Total Lines: 169263

Count Specific Files

./sloc.sh ./some/file.sh ./other/file.php ./and/another/test.pl