How to count lines of code in PHP files in a web application
https://www.zyxware.com/sites/default/files/styles/user_image/public/pictures/zyxlogo.png?itok=J9t-ZEoU
BY webmaster
5 years ago
Shell-Scripting
0 comments comment

Lines of code is typically indicative of effort that goes towards software development. So how do you count lines of code in your PHP application (or for that matter any specific types of files in any application). You can't manually open and count files, that would be a big waste of time. The *nix shell has a powerful set of tools that can help you count lines without having to do it manually.


find . -name "*.php" | xargs wc -l | awk '{print $1}' | awk '{total = total + $1}END{print total}'

The find command finds files named *.php (you can replace this with other patterns or sets of patterns with -o and -a). These files are passed to wc using xargs. wc prints out the list of files with the number of lines in each. The tabular output is then processed using awk to separate out just the column of line counts. This is then again processed using a bit of awk scripting.

I hope you got the general idea here on how these commands work to give you the number of lines of code in your PHP files. Happy coding.


RELATED ARTICLE

/themes/custom/zyxpro_light/images/placeholder.png
more_horiz
close

on 11th December 2008 / by webmaster
Recently we had to provide support on a Red Hat Server where there were hundreds of users and the user directories organized into hierarchies. Normally we change to a users directory using cd ~username. We had some extra time on our hands and wanted to play with the /etc/passwd file and tried to use awk to do the same thing. The following one liner will do this the hard way :-) Linux Shell Scripting Bash Leave a reply Your email address will not be published. Required fields are marked * cherry (not verified) access_time 13 Nov 2019 - 00:50 alternatively: cd `(cat /etc/passwd|grep username|cut -d ':' -f 6` ;-) Add new comment
/themes/custom/zyxpro_light/images/placeholder.png
close

on 12th December 2009 / by webmaster
Asianet Dataline is an ISP in Kerala and they use a web browser based authentication system to lo Internet Shell Scripting Bash Asianet Leave a reply Your email address will not be published. Required fields are marked * Vivek Thomas (not verified) access_time 13 Nov 2019 - 00:50 Thank you very much for this. Works great. Btw I had to add a --no-check-certificate option in the following line for it get the login URL. :) asianet_conn_url=`wget --quiet --no-check-certificate -O - www.zyxware.com|grep 'action='|sed 's/\(.*action="\)\(.*\)">/\2/g'` webmaster access_time 13 Nov 2019 - 00:50 In reply to Thank you very much for this. by Vivek Thomas (not verified) Changes duly made in git repo and credit given. Anoop JITHIN (not verified) access_time 13 Nov 2019 - 00:50 In reply to Thanks by webmaster Sir, Where is this "Favorite Scripts Folder" How Can I Copy A Script ie In Text Form To A Folde? Is Favorite Script Folder an attachment Of Internet Explorer Browser ? Please Tell Me About "START UP PROCESS" Can You Plese Explain What Should I Do Step By Step Considering Me As A Beginer. Jimmy (not verified) access_time 13 Nov 2019 - 00:50 Hi, I see the script. Can I use this script in Windows? If yes, please tell me the complete procedure to use this script in windows using the browser IE. Thanks Jimmy Anonymous (not verified) access_time 13 Nov 2019 - 00:50 Thank you very much for this. Works great. But I cant logout after use Add new comment
/themes/custom/zyxpro_light/images/placeholder.png
more_horiz
close

on 28th January 2012 / by webmaster
We had sometime back released an Utilities Internet Free Software Shell Scripting Reliance Python Leave a reply Your email address will not be published. Required fields are marked * Praveen Pious (not verified) access_time 13 Nov 2019 - 06:18 Not everyone is well versed with running python scripts on their windows machines. I downloaded and installed python off from their website. I set the environment variable correctly too. Yet, I am facing difficulty while trying to get this script working. Double clicking the script just makes a black command prompt prompt window to appear. Nothing seems to be happening on the background. So, please help me out. What am I doing wrong here? Anonymous (not verified) access_time 13 Nov 2019 - 06:18 i am using a connect broadband. and i don't know how to use a script. please tell me how use it? thanks in advance. Dhruv (not verified) access_time 13 Nov 2019 - 06:18 Even i'm having trouble getting this script working. Can you please tell this in layman terms? Hellobye80 (not verified) access_time 13 Nov 2019 - 06:18 from where can we download this free software. can you please share the link? Ethan Stone (not verified) access_time 13 Nov 2019 - 06:18 Is this script still working for you? Pagination Current page 1 Page 2 Next page Next › Last page Last » Add new comment
Leave a reply
Your email address will not be published. Required fields are marked *

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
The content of this field is kept private and will not be shown publicly.
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.