Line counting - how to exclude a folder?

bash

Solution

I couldn't make ruakh's solution work and ended up with the following instead:

find . -not -path '*/gen*' -a \( -name '*.java' -o -name '*.xml' \)

Also found an interesting `egrep` option based on GNU find:

find a/ -regextype egrep -not -path '*/gen*' -a -regex '.*(java|xml)$'

In order to count lines in the matched files you can stick `xargs cat | wc -l` on the end:

find . -not -path '*/gen*' -a \( -name '*.java' -o -name '*.xml' \) | xargs cat | wc -l

Problem

I'm using bash to count my lines of source in a project. Here's the code: ``` #!/bin/bash find . -name '*.java' | xargs wc -l find . -name '*.xml' | xargs wc -l ``` I want to exclude files from the ./gen folder. I think it's something to do with 'prune', but I can't figure out how to do it. EDIT Thankyou to ruakh, but his code wasn't my final solution, I had to make it count the lines again. Here's the finished thing if anybody wants it: ``` #!/bin/bash find . -path ./gen -prune -o -name '*.java' | xargs wc -l find . -name '*.xml' | xargs wc -l ```

Original source