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
  2. Make your bash shell cool again
  3. Looking for help
  4. Installing Flash 9 on Dapper
  5. Self Explanatory Perl Code