Skip to content

Perl Script to Count Lines of Code of Perl, PHP and HTML Files. This script counts all supported files in a directory and each subdirectory.

License

Notifications You must be signed in to change notification settings

echo2echo/Count-Lines-of-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

Count-Lines-of-Code

Perl Script to Count Lines of Code of Perl, PHP and HTML Files on Linux

Place script in directory with files and subdirectories to count

Grant permission to run script:

$ chmod 755 count_lines_of_code.pl

For script usage type the following without arguments.

$ ./count_lines_of_code.pl 

or

$ perldoc count_lines_of_code.pl

For example, to count lines of all the Perl files in a directory and each subdirectory:

$ ./count_lines_of_code.pl --type=Perl

For example, to count lines of all PHP files in a directory and each subdirectory:

$ ./count_lines_of_code.pl --type=PHP

There is now support for counting .shtml and .htm files along with vanilla .html files. Use flag --type=HTML for each variation

For example, to count lines of all HTML files in a directory and each subdirectory:

$ ./count_lines_of_code.pl --type=HTML

To count lines of code of a webpage, run something like the following in the same directory as the count_lines_of_code.pl script:

$ wget -cO - http://website.net > filename.html

Then run the script...

$ ./count_lines_of_code.pl --type=HTML

To get a count for a single HTML file try a variation of the following...

$ ./count_lines_of_code.pl --type=HTML | grep -A 4 "filename.html"

Or for a single Perl file...

$ ./count_lines_of_code.pl --type=Perl | grep -A 5 "filename.pl"

Files to be counted require read permission. If there is a permission error you could try running script with sudo, something like the following...

$ sudo ./count_lines_of_code.pl --type=Perl | grep -A 5 "filename.pl"

To omit/skip counting the lines of code of the script itself in the summary of results when counting perl lines try something like below...

--omit usage

$ ./count_lines_of_code.pl --type=Perl --omit=count_lines_of_code.pl

*** --omit flag is still a work in progress. As a temporary work around, place the count_lines_of_code.pl script in a directory with a least one other perl file to be counted. ***

Until the --omit flag is fixed you will need at least 1 other perl file in the same directory as you are using the script in. Maybe create a small .pl file with the command below. Yes, the --omit flag has a bug.

$ echo "Fill text for script functionality" > omit.pl

About

Perl Script to Count Lines of Code of Perl, PHP and HTML Files. This script counts all supported files in a directory and each subdirectory.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages