I wanted to count the lines of code on a project I am working on. From the base directory of the project, I wanted to line count all files ending with .php. I also needed to ignore the directories with test, model/om, cache and plugins. Using grep, find and wc you can do this:


#!/bin/bash
grep -v '^ *$' `find . -iname "*.php" | grep -v model\/om | grep -v \/test | grep -v \/cache | grep -v \/plugins | grep -v \/web | grep -v lib\/OFC` | wc -l

I am at 15645 lines of code, which includes comments. What are you at?

Related posts:

  1. Annoying people with code: A gentle introduction to C# and Mono Part 3: Creating a GUI (Graphical) Mono / C# Program In this post we will cover how to make a...
  2. Python and real time graphical analysis I have a camera which has a motor attached which...