Search code examples
ubuntuwcline-count

How can I count all of the lines in all of the files in the current directory and child directories?


I'm trying to figure out how many lines of code have been written for an app. Code is in the current directory and child directories. I'm using ubuntu.


Solution

  • find . -type f -name \*.c -exec wc -l {} \;  > /tmp/c_counts
    find . -type f -name \*.h -exec wc -l {} \;  > /tmp/h_counts
    

    This will produce the wc output for each file with a particular extension, one extension per /tmp file. You could run these results through a simple awk script to get the grand total, if that's what you need.